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