blob: 3763ca333c1abbd9cb70dd9b945ee2f3f3477e0a [file] [log] [blame]
Richard Smithd1386302017-05-04 00:29:54 +00001// RUN: rm -rf %t
2// RUN: mkdir %t
3// RUN: echo 'module foo { module a {} module b {} } module bar {}' > %t/module.map
4// RUN: %clang -cc1 -E -fmodules %s -verify -fmodule-name=foo -fmodule-map-file=%t/module.map
5// RUN: %clang -cc1 -E -fmodules %s -verify -fmodule-name=foo -fmodule-map-file=%t/module.map -fmodules-local-submodule-visibility -DLOCAL_VIS
Richard Smithc51c38b2017-04-29 00:34:47 +00006
7// Just checking the syntax here; the semantics are tested elsewhere.
Richard Smithd1386302017-05-04 00:29:54 +00008#pragma clang module import // expected-error {{expected module name}}
9#pragma clang module import ! // expected-error {{expected module name}}
10#pragma clang module import if // expected-error {{expected module name}}
11#pragma clang module import foo ? bar // expected-warning {{extra tokens at end of #pragma}}
12#pragma clang module import foo. // expected-error {{expected identifier after '.' in module name}}
13#pragma clang module import foo.bar.baz.quux // expected-error {{no submodule named 'bar' in module 'foo'}}
Richard Smithc51c38b2017-04-29 00:34:47 +000014
Richard Smithd1386302017-05-04 00:29:54 +000015#pragma clang module begin ! // expected-error {{expected module name}}
16
17#pragma clang module begin foo.a blah // expected-warning {{extra tokens}}
18 #pragma clang module begin foo.a // nesting is OK
19 #define X 1 // expected-note 0-1{{previous}}
20 #ifndef X
21 #error X should be defined here
22 #endif
23 #pragma clang module end
24
25 #ifndef X
26 #error X should still be defined
27 #endif
28#pragma clang module end foo.a // expected-warning {{extra tokens}}
29
30// #pragma clang module begin/end also import the module into the enclosing context
31#ifndef X
32#error X should still be defined
33#endif
34
35#pragma clang module begin foo.b
36 #if defined(X) && defined(LOCAL_VIS)
37 #error under -fmodules-local-submodule-visibility, X should not be defined
38 #endif
39
40 #if !defined(X) && !defined(LOCAL_VIS)
41 #error without -fmodules-local-submodule-visibility, X should still be defined
42 #endif
43
44 #pragma clang module import foo.a
45 #ifndef X
46 #error X should be defined here
47 #endif
48#pragma clang module end
49
50#pragma clang module end // expected-error {{no matching '#pragma clang module begin'}}
51#pragma clang module begin foo.a // expected-error {{no matching '#pragma clang module end'}}