Richard Smith | b920f85 | 2017-10-11 01:19:11 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fno-modules-error-recovery -fno-spell-checking -verify %s |
| 2 | |
| 3 | #pragma clang module build a |
| 4 | module a { explicit module b {} explicit module c {} } |
| 5 | #pragma clang module contents |
| 6 | |
| 7 | #pragma clang module begin a.b |
| 8 | namespace b { int n; } |
| 9 | #pragma clang module end |
| 10 | |
| 11 | #pragma clang module begin a.c |
| 12 | #pragma clang module import a.b |
| 13 | namespace c { using namespace b; } |
| 14 | #pragma clang module end |
| 15 | |
| 16 | #pragma clang module begin a |
| 17 | #pragma clang module import a.c |
| 18 | using namespace c; |
| 19 | #pragma clang module end |
| 20 | |
| 21 | #pragma clang module endbuild |
| 22 | |
| 23 | #pragma clang module import a.b |
| 24 | void use1() { |
| 25 | (void)n; // expected-error {{use of undeclared identifier}} |
| 26 | (void)::n; // expected-error {{no member named 'n' in the global namespace}} |
| 27 | (void)b::n; |
| 28 | } |
| 29 | namespace b { |
| 30 | void use1_in_b() { (void)n; } |
| 31 | } |
| 32 | namespace c { |
| 33 | void use1_in_c() { (void)n; } // expected-error {{use of undeclared identifier}} |
| 34 | } |
| 35 | |
| 36 | #pragma clang module import a.c |
| 37 | void use2() { |
| 38 | (void)n; // expected-error {{use of undeclared identifier}} |
| 39 | (void)::n; // expected-error {{no member named 'n' in the global namespace}} |
| 40 | (void)b::n; |
| 41 | (void)c::n; |
| 42 | } |
| 43 | namespace b { |
| 44 | void use2_in_b() { (void)n; } |
| 45 | } |
| 46 | namespace c { |
| 47 | void use2_in_c() { (void)n; } |
| 48 | } |
| 49 | |
| 50 | #pragma clang module import a |
| 51 | void use3() { |
| 52 | (void)n; |
| 53 | (void)::n; |
| 54 | (void)b::n; |
| 55 | (void)c::n; |
| 56 | } |
| 57 | namespace b { |
| 58 | void use3_in_b() { (void)n; } |
| 59 | } |
| 60 | namespace c { |
| 61 | void use3_in_c() { (void)n; } |
| 62 | } |