diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-30 05:22:59 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-30 05:22:59 +0000 |
commit | bb482b389e541428d0fa93c244d54d22eef3a384 (patch) | |
tree | 6c7c0e2c41d0211deb8f3b7b0c993e00407e470b /lib/Lex | |
parent | 4481b1f6f1590115e3acc6778c81bab7b7be74c1 (diff) |
Diagnose attempts to build a preprocessed module that defines an unavailable submodule.
The errors we would otherwise get are incomprehensible, as we would enter the
module but not make its contents visible to itself.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304190 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/Pragma.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index 2d078a4e76..e1d981527b 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -1407,6 +1407,24 @@ struct PragmaModuleBeginHandler : public PragmaHandler { M = NewM; } + // If the module isn't available, it doesn't make sense to enter it. + if (!M->isAvailable()) { + Module::Requirement Requirement; + Module::UnresolvedHeaderDirective MissingHeader; + (void)M->isAvailable(PP.getLangOpts(), PP.getTargetInfo(), + Requirement, MissingHeader); + if (MissingHeader.FileNameLoc.isValid()) { + PP.Diag(MissingHeader.FileNameLoc, diag::err_module_header_missing) + << MissingHeader.IsUmbrella << MissingHeader.FileName; + } else { + PP.Diag(M->DefinitionLoc, diag::err_module_unavailable) + << M->getFullModuleName() << Requirement.second << Requirement.first; + } + PP.Diag(BeginLoc, diag::note_pp_module_begin_here) + << M->getTopLevelModuleName(); + return; + } + // Enter the scope of the submodule. PP.EnterSubmodule(M, BeginLoc, /*ForPragma*/true); PP.EnterAnnotationToken(SourceRange(BeginLoc, ModuleName.back().second), |