Debian Codegraph @

clang/test/CXX/module/module.interface/p1.cpp

raw
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3
4 // RUN: %clang_cc1 -std=c++2a %t/errors.cpp -verify
5 // RUN: %clang_cc1 -std=c++2a %t/M.cppm -emit-module-interface -o %t/M.pcm
6 // RUN: %clang_cc1 -std=c++2a %t/impl.cpp -fmodule-file=M=%t/M.pcm -verify
7
8 //--- errors.cpp
9 module;
10 export int a; // expected-error {{export declaration can only be used within a module interface}}
11 export module M;
12 export int b; // #1
13 namespace N {
14 export int c; // #2
15 }
16
17 namespace { // expected-note 2{{anonymous namespace begins here}}
18 export int d1; // expected-error {{export declaration appears within anonymous namespace}}
19 namespace X {
20 export int d2; // expected-error {{export declaration appears within anonymous namespace}}
21 }
22 }
23
24 export export int e; // expected-error {{within another export declaration}}
25 export { export int f; } // expected-error {{within another export declaration}} expected-note {{export block begins here}}
26
27 module :private; // expected-note {{private module fragment begins here}}
28 export int priv; // expected-error {{export declaration cannot be used in a private module fragment}}
29
30 //--- M.cppm
31 export module M;
32 export int b;
33 namespace N {
34 export int c;
35 }
36
37 //--- impl.cpp
38 module M; // #M
39
40 export int b2; // expected-error {{export declaration can only be used within a module interface}}
41 namespace N {
42 export int c2; // expected-error {{export declaration can only be used within a module interface}}
43 }
44 // expected-note@#M 2+{{add 'export'}}