diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-10 22:35:27 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-10 22:35:27 +0000 |
commit | d97d35e1500d98f4f50938c5ecae98a1301a9a10 (patch) | |
tree | a25dd0bc78652222302147ca3b1cb546f9b7c6ad /clang/lib/Sema/SemaDecl.cpp | |
parent | 149178d92bf4d405e71fabb4d93204292f89acc2 (diff) | |
download | bcm5719-llvm-d97d35e1500d98f4f50938c5ecae98a1301a9a10.tar.gz bcm5719-llvm-d97d35e1500d98f4f50938c5ecae98a1301a9a10.zip |
[Modules TS] Diagnose attempts to enter module implementation units without the module interface being available.
llvm-svn: 315381
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a74cb57eab6..84cae84dec7 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -16168,6 +16168,7 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDecl(SourceLocation StartLoc, // implementation unit. That indicates the 'export' is missing. Diag(ModuleLoc, diag::err_module_interface_implementation_mismatch) << FixItHint::CreateInsertion(ModuleLoc, "export "); + MDK = ModuleDeclKind::Interface; break; case LangOptions::CMK_ModuleMap: @@ -16207,7 +16208,7 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDecl(SourceLocation StartLoc, assert(ModuleScopes.size() == 1 && "expected to be at global module scope"); switch (MDK) { - case ModuleDeclKind::Module: { + case ModuleDeclKind::Interface: { // We can't have parsed or imported a definition of this module or parsed a // module map defining it already. if (auto *M = Map.findModule(ModuleName)) { @@ -16237,14 +16238,16 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDecl(SourceLocation StartLoc, PP.getIdentifierInfo(ModuleName), Path[0].second); Mod = getModuleLoader().loadModule(ModuleLoc, Path, Module::AllVisible, /*IsIncludeDirective=*/false); - // FIXME: Produce an error in this case. - if (!Mod) + if (!Mod) { + Diag(ModuleLoc, diag::err_module_not_defined) << ModuleName; return nullptr; + } break; } // Switch from the global module to the named module. ModuleScopes.back().Module = Mod; + ModuleScopes.back().ModuleInterface = MDK != ModuleDeclKind::Implementation; VisibleModules.setVisible(Mod, ModuleLoc); // From now on, we have an owning module for all declarations we see. @@ -16430,8 +16433,7 @@ Decl *Sema::ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, // C++ Modules TS draft: // An export-declaration shall appear in the purview of a module other than // the global module. - if (ModuleScopes.empty() || - ModuleScopes.back().Module->Kind != Module::ModuleInterfaceUnit) + if (ModuleScopes.empty() || !ModuleScopes.back().ModuleInterface) Diag(ExportLoc, diag::err_export_not_in_module_interface); // An export-declaration [...] shall not contain more than one |