1// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t.0.pcm -verify -DTEST=0 2// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t.1.pcm -verify -DTEST=1 3// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -fmodule-file=foo=%t.0.pcm -o %t.2.pcm -verify -DTEST=2 4// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -fmodule-file=foo=%t.0.pcm -o %t.3.pcm -verify -Dfoo=bar -DTEST=3 5 6#if TEST == 0 || TEST == 2 7// expected-no-diagnostics 8#endif 9 10export module foo; 11 12static int m; 13 14int n; 15 16#if TEST == 0 17export { 18 int a; 19 int b; 20 constexpr int *p = &n; 21} 22export int c; 23 24namespace N { 25export void f() {} 26} // namespace N 27 28export struct T { 29} t; 30#elif TEST == 3 31int use_a = a; // expected-error {{use of undeclared identifier 'a'}} 32 33#undef foo 34import foo; // expected-error {{imports must immediately follow the module declaration}} 35 36export {} 37export { 38 ; // No diagnostic after P2615R1 DR 39} 40export { 41 static_assert(true); // No diagnostic after P2615R1 DR 42} 43 44int use_b = b; // expected-error{{use of undeclared identifier 'b'}} 45int use_n = n; // FIXME: this should not be visible, because it is not exported 46 47extern int n; 48static_assert(&n != p); // expected-error{{use of undeclared identifier 'p'}} 49#endif 50 51#if TEST == 1 52struct S { 53 export int n; // expected-error {{expected member name or ';'}} 54 export static int n; // expected-error {{expected member name or ';'}} 55}; 56#endif 57 58// FIXME: Exports of declarations without external linkage are disallowed. 59// Exports of declarations with non-external-linkage types are disallowed. 60 61// Cannot export within another export. This isn't precisely covered by the 62// language rules right now, but (per personal correspondence between zygoloid 63// and gdr) is the intent. 64#if TEST == 1 65export { // expected-note {{export block begins here}} 66 extern "C++" { 67 namespace NestedExport { 68 export { // expected-error {{export declaration appears within another export declaration}} 69 int q; 70 } 71 } // namespace NestedExport 72 } 73} 74#endif 75