1 | // RUN: rm -rf %t |
2 | // RUN: mkdir -p %t |
3 | // RUN: echo 'export module x; export int a, b;' > %t/x.cppm |
4 | // RUN: echo 'export module x.y; export int c;' > %t/x.y.cppm |
5 | // RUN: echo 'export module a.b; export int d;' > %t/a.b.cppm |
6 | // |
7 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm |
8 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm |
9 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/a.b.cppm -o %t/a.b.pcm |
10 | // |
11 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ |
12 | // RUN: -DMODULE_NAME=z -DINTERFACE |
13 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ |
14 | // RUN: -DMODULE_NAME=a.b |
15 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ |
16 | // RUN: -DMODULE_X -DMODULE_NAME=x |
17 | |
18 | #ifdef INTERFACE |
19 | export |
20 | #endif |
21 | module MODULE_NAME; |
22 | |
23 | int use_1 = a; |
24 | #if !MODULE_X |
25 | // expected-error@-2 {{declaration of 'a' must be imported from module 'x' before it is required}} |
26 | // expected-note@x.cppm:1 {{here}} |
27 | #endif |
28 | |
29 | import x; |
30 | |
31 | int use_2 = b; // ok |
32 | |
33 | // There is no relation between module x and module x.y. |
34 | int use_3 = c; // expected-error {{declaration of 'c' must be imported from module 'x.y'}} |
35 | // expected-note@x.y.cppm:1 {{here}} |
36 | |
37 | import x [[]]; |
38 | import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}} |
39 | import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}} |
40 | import x [[blarg::noreturn]]; // expected-warning {{unknown attribute 'noreturn' ignored}} |
41 | |
42 | import x.y; |
43 | import a.b; // Does not imply existence of module a. |
44 | import x.; // expected-error {{expected a module name after 'import'}} |
45 | import .x; // expected-error {{expected a module name after 'import'}} |
46 | |
47 | int use_4 = c; // ok |
48 | |
49 | import blarg; // expected-error {{module 'blarg' not found}} |
50 | |