1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc namespace N { struct X { }; }; 4f4a2713aSLionel Sambuc 5f4a2713aSLionel Sambuc namespace A = N; 6f4a2713aSLionel Sambuc 7f4a2713aSLionel Sambuc int B; // expected-note {{previous definition is here}} 8f4a2713aSLionel Sambuc namespace B = N; // expected-error {{redefinition of 'B' as different kind of symbol}} 9f4a2713aSLionel Sambuc 10f4a2713aSLionel Sambuc namespace C { } // expected-note {{previous definition is here}} 11f4a2713aSLionel Sambuc namespace C = N; // expected-error {{redefinition of 'C'}} 12f4a2713aSLionel Sambuc 13f4a2713aSLionel Sambuc int i; 14f4a2713aSLionel Sambuc namespace D = 15f4a2713aSLionel Sambuc i; // expected-error {{expected namespace name}} 16f4a2713aSLionel Sambuc 17f4a2713aSLionel Sambuc namespace E1 = N:: 18f4a2713aSLionel Sambuc Foo; // expected-error {{expected namespace name}} 19f4a2713aSLionel Sambuc namespace E2 = N:: 20f4a2713aSLionel Sambuc X; // expected-error {{expected namespace name}} 21f4a2713aSLionel Sambuc 22f4a2713aSLionel Sambuc namespace F { 23f4a2713aSLionel Sambuc namespace A { namespace B { } } // expected-note {{candidate found by name lookup is 'F::A::B'}} 24f4a2713aSLionel Sambuc namespace B { } // expected-note {{candidate found by name lookup is 'F::B'}} 25f4a2713aSLionel Sambuc using namespace A; 26f4a2713aSLionel Sambuc namespace D = B; // expected-error {{reference to 'B' is ambiguous}} 27f4a2713aSLionel Sambuc } 28f4a2713aSLionel Sambuc 29f4a2713aSLionel Sambuc namespace G { 30f4a2713aSLionel Sambuc namespace B = N; 31f4a2713aSLionel Sambuc } 32f4a2713aSLionel Sambuc 33f4a2713aSLionel Sambuc namespace H { 34f4a2713aSLionel Sambuc namespace A1 { } 35f4a2713aSLionel Sambuc namespace A2 { } 36f4a2713aSLionel Sambuc 37f4a2713aSLionel Sambuc // These all point to A1. 38*0a6a1f1dSLionel Sambuc namespace B = A1; 39f4a2713aSLionel Sambuc namespace B = A1; 40f4a2713aSLionel Sambuc namespace C = B; 41*0a6a1f1dSLionel Sambuc namespace B = C; // expected-note {{previously defined as an alias for 'A1'}} 42f4a2713aSLionel Sambuc 43*0a6a1f1dSLionel Sambuc namespace B = A2; // expected-error {{redefinition of 'B' as an alias for a different namespace}} 44f4a2713aSLionel Sambuc } 45f4a2713aSLionel Sambuc 46f4a2713aSLionel Sambuc namespace I { 47f4a2713aSLionel Sambuc namespace A1 { int i; } 48f4a2713aSLionel Sambuc 49f4a2713aSLionel Sambuc namespace A2 = A1; 50f4a2713aSLionel Sambuc } 51f4a2713aSLionel Sambuc f()52f4a2713aSLionel Sambucint f() { 53f4a2713aSLionel Sambuc return I::A2::i; 54f4a2713aSLionel Sambuc } 55f4a2713aSLionel Sambuc 56f4a2713aSLionel Sambuc namespace J { 57f4a2713aSLionel Sambuc namespace A { 58f4a2713aSLionel Sambuc namespace B { void func (); } 59f4a2713aSLionel Sambuc } 60f4a2713aSLionel Sambuc 61f4a2713aSLionel Sambuc namespace C = A; 62f4a2713aSLionel Sambuc 63f4a2713aSLionel Sambuc using namespace C::B; 64f4a2713aSLionel Sambuc g()65f4a2713aSLionel Sambuc void g() { 66f4a2713aSLionel Sambuc func(); 67f4a2713aSLionel Sambuc } 68f4a2713aSLionel Sambuc } 69f4a2713aSLionel Sambuc 70f4a2713aSLionel Sambuc namespace K { 71f4a2713aSLionel Sambuc namespace KA { void func(); } 72f4a2713aSLionel Sambuc f()73f4a2713aSLionel Sambuc void f() { 74f4a2713aSLionel Sambuc namespace KB = KA; 75f4a2713aSLionel Sambuc KB::func(); 76f4a2713aSLionel Sambuc } 77f4a2713aSLionel Sambuc g()78f4a2713aSLionel Sambuc template <class T> void g() { 79f4a2713aSLionel Sambuc namespace KC = KA; 80f4a2713aSLionel Sambuc KC::func(); 81f4a2713aSLionel Sambuc } 82f4a2713aSLionel Sambuc template void g<int>(); 83f4a2713aSLionel Sambuc template void g<long>(); 84f4a2713aSLionel Sambuc h()85f4a2713aSLionel Sambuc void h() { 86f4a2713aSLionel Sambuc KB::func(); // expected-error {{undeclared identifier 'KB'}} 87f4a2713aSLionel Sambuc KC::func(); // expected-error {{undeclared identifier 'KC'}} 88f4a2713aSLionel Sambuc } 89f4a2713aSLionel Sambuc } 90f4a2713aSLionel Sambuc 91f4a2713aSLionel Sambuc namespace { 92f4a2713aSLionel Sambuc class C1; 93f4a2713aSLionel Sambuc } 94f4a2713aSLionel Sambuc namespace { 95f4a2713aSLionel Sambuc class C1; 96f4a2713aSLionel Sambuc } 97f4a2713aSLionel Sambuc C1 *pc1 = 0; 98f4a2713aSLionel Sambuc 99f4a2713aSLionel Sambuc namespace N { 100f4a2713aSLionel Sambuc namespace { 101f4a2713aSLionel Sambuc class C2; 102f4a2713aSLionel Sambuc } 103f4a2713aSLionel Sambuc } 104f4a2713aSLionel Sambuc namespace N { 105f4a2713aSLionel Sambuc namespace { 106f4a2713aSLionel Sambuc class C2; 107f4a2713aSLionel Sambuc } 108f4a2713aSLionel Sambuc } 109f4a2713aSLionel Sambuc N::C2 *pc2 = 0; 110f4a2713aSLionel Sambuc 111f4a2713aSLionel Sambuc // PR6341 112f4a2713aSLionel Sambuc namespace A = N; 113f4a2713aSLionel Sambuc namespace N { } 114f4a2713aSLionel Sambuc namespace A = N; 115f4a2713aSLionel Sambuc 116f4a2713aSLionel Sambuc A::X nx; 117f4a2713aSLionel Sambuc 118f4a2713aSLionel Sambuc namespace PR7014 { 119f4a2713aSLionel Sambuc namespace X 120f4a2713aSLionel Sambuc { 121f4a2713aSLionel Sambuc namespace Y {} 122f4a2713aSLionel Sambuc } 123f4a2713aSLionel Sambuc 124f4a2713aSLionel Sambuc using namespace X; 125f4a2713aSLionel Sambuc 126f4a2713aSLionel Sambuc namespace Y = X::Y; 127f4a2713aSLionel Sambuc } 128