Debian Codegraph @

clang/test/CXX/module/module.unit/p8.cpp

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: split-file %s %t
4 // RUN: echo 'export module foo;' > %t.cppm
5 // RUN: echo 'export int n;' >> %t.cppm
6 // RUN: %clang_cc1 -std=c++2a %t.cppm -emit-module-interface -o %t.pcm
7 // RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=0 %t/A.cppm
8 // RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=1 %t/B.cppm
9 // RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=2 %t/C.cppm
10 // RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=3 %t/D.cppm
11 // RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=4 %t/E.cppm
12 // RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=5 %t/F.cppm
13
14 //--- A.cppm
15 // no module declaration
16 // expected-no-diagnostics
17
18 //--- B.cppm
19 // expected-no-diagnostics
20 module foo; // Implementation, implicitly imports foo.
21 #define IMPORTED
22
23 int k = n;
24
25 //--- C.cppm
26 export module foo;
27
28 int k = n; // expected-error {{use of undeclared identifier 'n'}}
29
30 //--- D.cppm
31 export module bar; // A different module
32
33 int k = n; // expected-error {{use of undeclared identifier 'n'}}
34
35 //--- E.cppm
36 module foo:bar; // Partition implementation
37 //#define IMPORTED (we don't import foo here)
38
39 int k = n; // expected-error {{use of undeclared identifier 'n'}}
40
41 //--- F.cppm
42 export module foo:bar; // Partition interface
43 //#define IMPORTED (we don't import foo here)
44
45 int k = n; // expected-error {{use of undeclared identifier 'n'}}