aboutsummaryrefslogtreecommitdiff
path: root/clang/test/CXX/module/module.unit/p8.cpp
blob: fb190257d3a2394b45ac6e5cafff6ef6a47444ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t
// RUN: echo 'export module foo;' > %t.cppm
// RUN: echo 'export int n;' >> %t.cppm
// RUN: %clang_cc1 -std=c++2a %t.cppm -emit-module-interface -o %t.pcm
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=0 %t/A.cppm
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=1 %t/B.cppm
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=2 %t/C.cppm
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=3 %t/D.cppm
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=4 %t/E.cppm
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=5 %t/F.cppm

//--- A.cppm
// no module declaration
// expected-no-diagnostics

//--- B.cppm
// expected-no-diagnostics
module foo; // Implementation, implicitly imports foo.
#define IMPORTED

int k = n;

//--- C.cppm
export module foo;

int k = n; // expected-error {{use of undeclared identifier 'n'}}

//--- D.cppm
export module bar; // A different module

int k = n; // expected-error {{use of undeclared identifier 'n'}}

//--- E.cppm
module foo:bar; // Partition implementation
//#define IMPORTED (we don't import foo here)

int k = n; // expected-error {{use of undeclared identifier 'n'}}

//--- F.cppm
export module foo:bar; // Partition interface
//#define IMPORTED  (we don't import foo here)

int k = n; // expected-error {{use of undeclared identifier 'n'}}