63 lines · cpp
1// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fno-modules-error-recovery -fno-spell-checking -verify %s2 3#pragma clang module build a4module a { explicit module b {} explicit module c {} }5#pragma clang module contents6 7#pragma clang module begin a.b8namespace b { int n; }9#pragma clang module end10 11#pragma clang module begin a.c12#pragma clang module import a.b13namespace c { using namespace b; }14#pragma clang module end15 16#pragma clang module begin a17#pragma clang module import a.c18using namespace c;19#pragma clang module end20 21#pragma clang module endbuild22 23#pragma clang module import a.b24void 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}29namespace b {30 void use1_in_b() { (void)n; }31}32namespace c {33 void use1_in_c() { (void)n; } // expected-error {{use of undeclared identifier}}34}35 36#pragma clang module import a.c37void 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}43namespace b {44 void use2_in_b() { (void)n; }45}46namespace c {47 void use2_in_c() { (void)n; }48}49 50#pragma clang module import a51void use3() {52 (void)n;53 (void)::n;54 (void)b::n;55 (void)c::n;56}57namespace b {58 void use3_in_b() { (void)n; }59}60namespace c {61 void use3_in_c() { (void)n; }62}63