Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / dcl.dcl / basic.namespace / namespace.udir / p1.cpp
blob20a19ab042500633f7063862b43d7f970fa48775
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // (this actually occurs before paragraph 1)
4 namespace test0 {
5 namespace A {}
6 class B {
7 using namespace A; // expected-error {{'using namespace' is not allowed in classes}}
8 };
12 struct opaque0 {};
13 struct opaque1 {};
15 // Test that names appear as if in deepest common ancestor.
16 namespace test1 {
17 namespace A {
18 namespace B {
19 opaque0 foo(); // expected-note {{candidate}}
23 namespace C {
24 opaque1 foo(); // expected-note {{candidate}}
26 opaque1 test() {
27 using namespace A::B;
28 return foo(); // C::foo
32 opaque1 test() {
33 using namespace A::B;
34 using namespace C;
35 return foo(); // expected-error {{call to 'foo' is ambiguous}}
39 // Same thing, but with the directives in namespaces.
40 namespace test2 {
41 namespace A {
42 namespace B {
43 opaque0 foo(); // expected-note {{candidate}}
47 namespace C {
48 opaque1 foo(); // expected-note {{candidate}}
50 namespace test {
51 using namespace A::B;
53 opaque1 test() {
54 return foo(); // C::foo
59 namespace test {
60 using namespace A::B;
61 using namespace C;
63 opaque1 test() {
64 return foo(); // expected-error {{call to 'foo' is ambiguous}}
69 // Transitivity.
70 namespace test3 {
71 namespace A {
72 namespace B {
73 opaque0 foo();
76 namespace C {
77 using namespace A;
80 opaque0 test0() {
81 using namespace C;
82 using namespace B;
83 return foo();
86 namespace D {
87 using namespace C;
89 namespace A {
90 opaque1 foo();
93 opaque1 test1() {
94 using namespace D;
95 return foo();
99 // Transitivity acts like synthetic using directives.
100 namespace test4 {
101 namespace A {
102 namespace B {
103 opaque0 foo(); // expected-note {{candidate}}
107 namespace C {
108 using namespace A::B;
111 opaque1 foo(); // expected-note {{candidate}}
113 namespace A {
114 namespace D {
115 using namespace C;
118 opaque0 test() {
119 using namespace D;
120 return foo();
124 opaque0 test() {
125 using namespace A::D;
126 return foo(); // expected-error {{call to 'foo' is ambiguous}}
130 // Bug: using directives should be followed when parsing default
131 // arguments in scoped declarations.
132 class test5 {
133 int inc(int x);
135 namespace Test5 {
136 int default_x = 0;
138 using namespace Test5;
139 int test5::inc(int x = default_x) {
140 return x+1;