nested-name-spec.cpp revision 011bb4edf731d529da1cbf71c7c2696aaf5a054f
1// RUN: clang -fsyntax-only -verify %s 2namespace A { 3 struct C { 4 static int cx; 5 }; 6 int ax; 7 void Af(); 8} 9 10A:: ; // expected-error {{expected unqualified-id}} 11::A::ax::undef ex3; // expected-error {{expected a class or namespace}} expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}} 12A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}} expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}} 13 14class C2 { 15 void m(); 16 int x; 17}; 18 19void C2::m() { 20 x = 0; 21} 22 23namespace B { 24 void ::A::Af() {} // expected-error {{definition or redeclaration of 'Af' not in a namespace enclosing 'A'}} 25} 26 27void f1() { 28 void A::Af(); // expected-error {{definition or redeclaration of 'Af' not allowed inside a function}} 29} 30 31void f2() { 32 A:: ; // expected-error {{expected unqualified-id}} 33 A::C::undef = 0; // expected-error {{no member named 'undef'}} 34 ::A::C::cx = 0; 35 int x = ::A::ax = A::C::cx; 36 x = sizeof(A::C); 37 x = sizeof(::A::C::cx); 38} 39 40A::C c1; 41struct A::C c2; 42struct S : public A::C {}; 43struct A::undef; // expected-error {{'undef' does not name a tag member in the specified scope}} 44 45namespace A2 { 46 typedef int INT; 47 struct RC; 48 struct CC { 49 struct NC; 50 }; 51} 52 53struct A2::RC { 54 INT x; 55}; 56 57struct A2::CC::NC { 58 void m() {} 59}; 60 61void f3() { 62 N::x = 0; // expected-error {{use of undeclared identifier 'N'}} 63 int N; 64 N::x = 0; // expected-error {{expected a class or namespace}} 65 { int A; A::ax = 0; } 66 { enum A {}; A::ax = 0; } 67 { enum A { A }; A::ax = 0; } 68 { typedef int A; A::ax = 0; } 69 { typedef int A(); A::ax = 0; } 70 { typedef A::C A; A::ax = 0; } // expected-error {{no member named 'ax'}} 71 { typedef A::C A; A::cx = 0; } 72} 73 74// make sure the following doesn't hit any asserts 75void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} // expected-error {{expected ')'}} expected-error {{to match this '('}} // expected-error {{variable has incomplete type 'void'}} 76