2008-12-16 14:37:47 +08:00
// RUN: clang -fsyntax-only -verify -std=c++98 %s
2008-11-09 01:17:31 +08:00
namespace A {
struct C {
static int cx ;
} ;
int ax ;
void Af ( ) ;
}
A : : ; // expected-error {{expected unqualified-id}}
: : A : : ax : : undef ex3 ; // expected-error {{expected a class or namespace}} expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}}
A : : undef1 : : undef2 ex4 ; // expected-error {{no member named 'undef1'}} expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}}
class C2 {
2008-12-16 07:53:10 +08:00
void m ( ) ; // expected-note{{member declaration nearly matches}}
void f ( const int & parm ) ; // expected-note{{member declaration nearly matches}}
void f ( int ) const ; // expected-note{{member declaration nearly matches}}
void f ( float ) ;
2008-11-09 01:17:31 +08:00
int x ;
} ;
2008-12-16 07:53:10 +08:00
void C2 : : m ( ) const { } // expected-error{{out-of-line definition does not match any declaration in 'C2'}}
void C2 : : f ( int ) { } // expected-error{{out-of-line definition does not match any declaration in 'C2'}}
2008-11-09 01:17:31 +08:00
void C2 : : m ( ) {
x = 0 ;
}
namespace B {
2008-11-24 04:28:15 +08:00
void : : A : : Af ( ) { } // expected-error {{definition or redeclaration of 'Af' not in a namespace enclosing 'A'}}
2008-11-09 01:17:31 +08:00
}
void f1 ( ) {
2008-12-16 07:53:10 +08:00
void A : : Af ( ) ; // expected-error {{definition or redeclaration of 'Af' not allowed inside a function}}
2008-11-09 01:17:31 +08:00
}
void f2 ( ) {
A : : ; // expected-error {{expected unqualified-id}}
A : : C : : undef = 0 ; // expected-error {{no member named 'undef'}}
: : A : : C : : cx = 0 ;
int x = : : A : : ax = A : : C : : cx ;
x = sizeof ( A : : C ) ;
x = sizeof ( : : A : : C : : cx ) ;
}
A : : C c1 ;
struct A : : C c2 ;
struct S : public A : : C { } ;
struct A : : undef ; // expected-error {{'undef' does not name a tag member in the specified scope}}
2008-11-10 07:41:00 +08:00
namespace A2 {
typedef int INT ;
struct RC ;
2008-11-20 02:01:13 +08:00
struct CC {
struct NC ;
} ;
2008-11-10 07:41:00 +08:00
}
struct A2 : : RC {
INT x ;
} ;
2008-11-20 02:01:13 +08:00
struct A2 : : CC : : NC {
void m ( ) { }
} ;
2008-11-09 01:17:31 +08:00
void f3 ( ) {
N : : x = 0 ; // expected-error {{use of undeclared identifier 'N'}}
int N ;
N : : x = 0 ; // expected-error {{expected a class or namespace}}
{ int A ; A : : ax = 0 ; }
2008-12-16 14:37:47 +08:00
{ typedef int A ; A : : ax = 0 ; } // expected-error{{expected a class or namespace}}
{ int A ( ) ; A : : ax = 0 ; }
2008-11-09 01:17:31 +08:00
{ typedef A : : C A ; A : : ax = 0 ; } // expected-error {{no member named 'ax'}}
{ typedef A : : C A ; A : : cx = 0 ; }
}
2008-11-19 23:22:16 +08:00
// make sure the following doesn't hit any asserts
2008-11-24 07:17:07 +08:00
void f4 ( undef : : C ) ; // expected-error {{use of undeclared identifier 'undef'}} // expected-error {{expected ')'}} expected-note {{to match this '('}} // expected-error {{variable has incomplete type 'void'}}
2008-12-16 07:53:10 +08:00
typedef void C2 : : f5 ( int ) ; // expected-error{{typedef declarator cannot be qualified}}
void f6 ( int A2 : : RC : : x ) ; // expected-error{{parameter declarator cannot be qualified}}
int A2 : : RC : : x ; // expected-error{{non-static data member defined out-of-line}}
void A2 : : CC : : NC : : m ( ) ; // expected-error{{out-of-line declaration of a member must be a definition}}
2008-12-16 14:37:47 +08:00
namespace E {
int X = 5 ;
namespace Nested {
enum E {
X = 0
} ;
void f ( ) {
return E : : X ; // expected-error{{expected a class or namespace}}
}
}
}
2008-12-26 23:00:45 +08:00
class Operators {
Operators operator + ( const Operators & ) const ; // expected-note{{member declaration nearly matches}}
operator bool ( ) ;
} ;
Operators Operators : : operator + ( const Operators & ) { // expected-error{{out-of-line definition does not match any declaration in 'Operators'}}
Operators ops ;
return ops ;
}
Operators Operators : : operator + ( const Operators & ) const {
Operators ops ;
return ops ;
}
Operators : : operator bool ( ) {
return true ;
}