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