xref: /llvm-project/clang/test/CXX/module/module.interface/p1.cpp (revision 57833636816a13ccda53714413c532dc81e3b5ff)
1 // RUN: %clang_cc1 -std=c++2a %s -DERRORS -verify
2 // RUN: %clang_cc1 -std=c++2a %s -emit-module-interface -o %t.pcm
3 // RUN: %clang_cc1 -std=c++2a %s -fmodule-file=M=%t.pcm -DIMPLEMENTATION -verify -Db=b2 -Dc=c2
4 
5 module;
6 
7 #ifdef ERRORS
8 export int a; // expected-error {{export declaration can only be used within a module purview}}
9 #endif
10 
11 #ifndef IMPLEMENTATION
12 export
13 #else
14 // expected-error@#1 {{export declaration can only be used within a module purview}}
15 // expected-error@#2 {{export declaration can only be used within a module purview}}
16 // expected-note@+2 1+{{add 'export'}}
17 #endif
18 module M;
19 
20 export int b; // #1
21 namespace N {
22   export int c; // #2
23 }
24 
25 #ifdef ERRORS
26 namespace { // expected-note 2{{anonymous namespace begins here}}
27   export int d1; // expected-error {{export declaration appears within anonymous namespace}}
28   namespace X {
29     export int d2; // expected-error {{export declaration appears within anonymous namespace}}
30   }
31 }
32 
33 export export int e; // expected-error {{within another export declaration}}
34 export { export int f; } // expected-error {{within another export declaration}} expected-note {{export block begins here}}
35 
36 module :private; // expected-note {{private module fragment begins here}}
37 export int priv; // expected-error {{export declaration cannot be used in a private module fragment}}
38 #endif
39