[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / using-directive.cpp
blob6ca5c6eab4f9b045d64e27934ac74e43069e782f
1 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fno-modules-error-recovery -fno-spell-checking -verify %s
3 #pragma clang module build a
4 module a { explicit module b {} explicit module c {} }
5 #pragma clang module contents
7 #pragma clang module begin a.b
8 namespace b { int n; }
9 #pragma clang module end
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
16 #pragma clang module begin a
17 #pragma clang module import a.c
18 using namespace c;
19 #pragma clang module end
21 #pragma clang module endbuild
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;
29 namespace b {
30 void use1_in_b() { (void)n; }
32 namespace c {
33 void use1_in_c() { (void)n; } // expected-error {{use of undeclared identifier}}
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;
43 namespace b {
44 void use2_in_b() { (void)n; }
46 namespace c {
47 void use2_in_c() { (void)n; }
50 #pragma clang module import a
51 void use3() {
52 (void)n;
53 (void)::n;
54 (void)b::n;
55 (void)c::n;
57 namespace b {
58 void use3_in_b() { (void)n; }
60 namespace c {
61 void use3_in_c() { (void)n; }