1 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s
15 A:: ; // expected-error {{expected unqualified-id}}
16 ::A::ax::undef ex3; // expected-error {{no member named}}
17 A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}}
19 int A::C::Ag1() { return 0; }
21 static int A::C::Ag2() { return 0; } // expected-error{{'static' can}}
26 static int A::C::cx2 = 17; // expected-error{{'static' can}}
29 void m(); // expected-note{{member declaration nearly matches}}
31 void f(const int& parm); // expected-note{{member declaration nearly matches}}
32 void f(int) const; // expected-note{{member declaration nearly matches}}
38 void C2::m() const { } // expected-error{{out-of-line definition of 'm' does not match any declaration in 'class C2'}}
40 void C2::f(int) { } // expected-error{{out-of-line definition of 'f' does not match any declaration in 'class C2'}}
47 void ::A::Af() {} // expected-error {{definition or redeclaration of 'Af' not in a namespace enclosing 'A'}}
51 void A::Af(); // expected-error {{definition or redeclaration of 'Af' not allowed inside a function}}
55 A:: ; // expected-error {{expected unqualified-id}}
56 A::C::undef = 0; // expected-error {{no member named 'undef'}}
58 int x = ::A::ax = A::C::cx;
60 x = sizeof(::A::C::cx);
65 struct S : public A::C {};
66 struct A::undef; // expected-error {{'undef' does not name a tag member in the specified scope}}
85 N::x = 0; // expected-error {{use of undeclared identifier 'N'}}
87 N::x = 0; // expected-error {{expected a class or namespace}}
89 { typedef int A; A::ax = 0; } // expected-error{{expected a class or namespace}}
90 { typedef A::C A; A::ax = 0; } // expected-error {{no member named 'ax'}}
91 { typedef A::C A; A::cx = 0; }
94 // make sure the following doesn't hit any asserts
95 void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} \
96 expected-error {{variable has incomplete type 'void'}}
98 typedef void C2::f5(int); // expected-error{{typedef declarator cannot be qualified}}
100 void f6(int A2::RC::x); // expected-error{{parameter declarator cannot be qualified}}
102 int A2::RC::x; // expected-error{{non-static data member defined out-of-line}}
104 void A2::CC::NC::m(); // expected-error{{out-of-line declaration of a member must be a definition}}
116 return E::X; // expected-error{{expected a class or namespace}}
123 Operators operator+(const Operators&) const; // expected-note{{member declaration nearly matches}}
127 Operators Operators::operator+(const Operators&) { // expected-error{{out-of-line definition of 'operator+' does not match any declaration in 'class Operators'}}
132 Operators Operators::operator+(const Operators&) const {
137 Operators::operator bool() {
142 void g(int&); // expected-note{{member declaration nearly matches}}
145 void A::f() {} // expected-error{{out-of-line definition of 'f' does not match any declaration in namespace 'A'}}
147 void A::g(const int&) { } // expected-error{{out-of-line definition of 'g' does not match any declaration in namespace 'A'}}
151 void Struct::f() { } // expected-error{{out-of-line definition of 'f' does not match any declaration in 'struct Struct'}}
153 void global_func(int);
154 void global_func2(int);
157 void ::global_func(int) { } // expected-error{{definition or redeclaration of 'global_func' cannot name the global scope}}
160 // FIXME: if we move this to a separate definition of N, things break!
162 void ::global_func2(int) { } // expected-error{{definition or redeclaration of 'global_func2' cannot name the global scope}}
164 void N::f() { } // okay
166 struct Y; // expected-note{{forward declaration of 'struct Y'}}
167 Y::foo y; // expected-error{{incomplete type 'struct Y' named in nested name specifier}} \
168 // expected-error{{no type named 'foo' in}}
170 X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}} \
171 // expected-error{{C++ requires a type specifier for all declarations}} \
172 // expected-error{{only constructors take base initializers}}
181 struct a { }; // expected-note{{candidate function}}
184 template <typename T>
190 foo<somens:a> a2; // expected-error {{unexpected ':' in nested name specifier}}
192 somens::a a3 = a2; // expected-error {{no viable conversion}}
194 // typedefs and using declarations.
197 class Counter { static int count; };
198 typedef Counter counter;
211 // We still need to do lookup in the lexical scope, even if we push a
212 // non-lexical scope.
221 int *ns::count_ptr = &count;