2011-01-20 00:41:58 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
|
2008-11-08 23:40:37 +08:00
|
|
|
class C;
|
2008-06-25 06:12:16 +08:00
|
|
|
class C {
|
|
|
|
public:
|
|
|
|
protected:
|
|
|
|
typedef int A,B;
|
|
|
|
static int sf(), u;
|
|
|
|
|
|
|
|
struct S {};
|
2010-07-13 14:24:26 +08:00
|
|
|
enum {}; // expected-warning{{declaration does not declare anything}}
|
2010-04-09 05:33:23 +08:00
|
|
|
int; // expected-warning {{declaration does not declare anything}}
|
2008-06-28 16:10:48 +08:00
|
|
|
int : 1, : 2;
|
2008-06-25 06:12:16 +08:00
|
|
|
|
|
|
|
public:
|
2012-07-23 13:45:25 +08:00
|
|
|
void m0() {}; // ok, one extra ';' is permitted
|
|
|
|
void m1() {}
|
|
|
|
; // ok, one extra ';' is permitted
|
2008-06-25 06:12:16 +08:00
|
|
|
void m() {
|
|
|
|
int l = 2;
|
2012-07-23 13:45:25 +08:00
|
|
|
};; // expected-warning{{extra ';' after member function definition}}
|
2011-01-20 00:41:58 +08:00
|
|
|
|
2012-05-17 03:04:59 +08:00
|
|
|
template<typename T> void mt(T) { }
|
2012-07-23 13:45:25 +08:00
|
|
|
;
|
2011-01-20 00:41:58 +08:00
|
|
|
; // expected-warning{{extra ';' inside a class}}
|
|
|
|
|
2008-11-08 23:40:37 +08:00
|
|
|
virtual int vf() const volatile = 0;
|
2008-06-25 06:12:16 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
int x,f(),y,g();
|
2008-11-08 23:40:37 +08:00
|
|
|
inline int h();
|
|
|
|
static const int sci = 10;
|
2008-11-15 07:42:31 +08:00
|
|
|
mutable int mi;
|
2008-06-25 06:12:16 +08:00
|
|
|
};
|
2008-11-08 23:40:37 +08:00
|
|
|
void glo()
|
|
|
|
{
|
|
|
|
struct local {};
|
|
|
|
}
|
2008-12-18 09:12:00 +08:00
|
|
|
|
|
|
|
// PR3177
|
|
|
|
typedef union {
|
|
|
|
__extension__ union {
|
|
|
|
int a;
|
|
|
|
float b;
|
|
|
|
} y;
|
|
|
|
} bug3177;
|
|
|
|
|
2011-10-13 14:08:43 +08:00
|
|
|
// check that we don't consume the token after the access specifier
|
|
|
|
// when it's not a colon
|
|
|
|
class D {
|
|
|
|
public // expected-error{{expected ':'}}
|
|
|
|
int i;
|
|
|
|
};
|
|
|
|
|
|
|
|
// consume the token after the access specifier if it's a semicolon
|
|
|
|
// that was meant to be a colon
|
|
|
|
class E {
|
|
|
|
public; // expected-error{{expected ':'}}
|
|
|
|
int i;
|
|
|
|
};
|
|
|
|
|
2012-01-21 10:59:18 +08:00
|
|
|
class F {
|
|
|
|
int F1 { return 1; } // expected-error{{function definition does not declare parameters}}
|
|
|
|
void F2 {} // expected-error{{function definition does not declare parameters}}
|
|
|
|
typedef int F3() { return 0; } // expected-error{{function definition declared 'typedef'}}
|
|
|
|
typedef void F4() {} // expected-error{{function definition declared 'typedef'}}
|
|
|
|
};
|
|
|
|
|
2012-03-27 08:56:56 +08:00
|
|
|
namespace ctor_error {
|
|
|
|
class Foo {};
|
|
|
|
// By [class.qual]p2, this is a constructor declaration.
|
|
|
|
Foo::Foo (F) = F(); // expected-error{{does not match any declaration in 'ctor_error::Foo'}}
|
|
|
|
|
|
|
|
class Ctor { // expected-note{{not complete until the closing '}'}}
|
|
|
|
Ctor(f)(int); // ok
|
|
|
|
Ctor(g(int)); // ok
|
|
|
|
Ctor(x[5]); // expected-error{{incomplete type}}
|
|
|
|
|
|
|
|
Ctor(UnknownType *); // expected-error{{unknown type name 'UnknownType'}}
|
2012-03-29 09:46:00 +08:00
|
|
|
void operator+(UnknownType*); // expected-error{{unknown type name 'UnknownType'}}
|
2012-03-27 08:56:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Ctor::Ctor (x) = { 0 }; // \
|
|
|
|
// expected-error{{qualified reference to 'Ctor' is a constructor name}}
|
|
|
|
|
|
|
|
Ctor::Ctor(UnknownType *) {} // \
|
2012-03-29 09:46:00 +08:00
|
|
|
// expected-error{{unknown type name 'UnknownType'}}
|
|
|
|
void Ctor::operator+(UnknownType*) {} // \
|
|
|
|
// expected-error{{unknown type name 'UnknownType'}}
|
2012-03-27 08:56:56 +08:00
|
|
|
}
|
|
|
|
|
2011-10-13 14:08:43 +08:00
|
|
|
// PR11109 must appear at the end of the source file
|
|
|
|
class pr11109r3 { // expected-note{{to match this '{'}}
|
|
|
|
public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}
|