File tree Expand file tree Collapse file tree 4 files changed +22
-1
lines changed
CXX/module/dcl.dcl/dcl.module/dcl.module.interface Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -11693,6 +11693,8 @@ def err_module_not_defined : Error<
11693
11693
def err_module_redeclaration : Error<
11694
11694
"translation unit contains multiple module declarations">;
11695
11695
def note_prev_module_declaration : Note<"previous module declaration is here">;
11696
+ def err_module_declaration_missing : Error<
11697
+ "missing 'export module' declaration in module interface unit">;
11696
11698
def err_module_declaration_missing_after_global_module_introducer : Error<
11697
11699
"missing 'module' declaration at end of global module fragment "
11698
11700
"introduced here">;
Original file line number Diff line number Diff line change @@ -1272,6 +1272,18 @@ void Sema::ActOnEndOfTranslationUnit() {
1272
1272
Module::ExplicitGlobalModuleFragment) {
1273
1273
Diag (ModuleScopes.back ().BeginLoc ,
1274
1274
diag::err_module_declaration_missing_after_global_module_introducer);
1275
+ } else if (getLangOpts ().getCompilingModule () ==
1276
+ LangOptions::CMK_ModuleInterface &&
1277
+ // We can't use ModuleScopes here since ModuleScopes is always
1278
+ // empty if we're compiling the BMI.
1279
+ !getASTContext ().getCurrentNamedModule ()) {
1280
+ // If we are building a module interface unit, we should have seen the
1281
+ // module declaration.
1282
+ //
1283
+ // FIXME: Make a better guess as to where to put the module declaration.
1284
+ Diag (getSourceManager ().getLocForStartOfFile (
1285
+ getSourceManager ().getMainFileID ()),
1286
+ diag::err_module_declaration_missing);
1275
1287
}
1276
1288
1277
1289
// Now we can decide whether the modules we're building need an initializer.
Original file line number Diff line number Diff line change 1
- // RUN: %clang_cc1 -std=c++20 %s -verify -o /dev/null
1
+ // RUN: %clang_cc1 -std=c++20 %s -verify -emit-module-interface - o /dev/null
2
2
// RUN: %clang_cc1 -std=c++20 %s -DINTERFACE -verify -emit-module-interface -o %t
3
3
// RUN: %clang_cc1 -std=c++20 %s -DIMPLEMENTATION -verify -fmodule-file=A=%t -o /dev/null
4
4
//
@@ -15,6 +15,8 @@ module A; // #module-decl
15
15
// expected-error@-2 {{missing 'export' specifier in module declaration while building module interface}}
16
16
#define INTERFACE
17
17
#endif
18
+ #else // Not in a module
19
+ // expected-error@* {{missing 'export module' declaration in module interface unit}}
18
20
#endif
19
21
20
22
#ifndef INTERFACE
Original file line number Diff line number Diff line change
1
+ // RUN: mkdir -p %t
2
+ // RUN: %clang -std=c++20 -xc++-module %s -Xclang -verify --precompile -o %t/tmp.pcm
3
+ // not modules
4
+
5
+ // expected-error@* {{missing 'export module' declaration in module interface unit}}
You can’t perform that action at this time.
0 commit comments