1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s 2*f4a2713aSLionel Sambuc class C; 3*f4a2713aSLionel Sambuc class C { 4*f4a2713aSLionel Sambuc public: 5*f4a2713aSLionel Sambuc protected: 6*f4a2713aSLionel Sambuc typedef int A,B; 7*f4a2713aSLionel Sambuc static int sf(), u; 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc struct S {}; 10*f4a2713aSLionel Sambuc enum {}; // expected-warning{{declaration does not declare anything}} 11*f4a2713aSLionel Sambuc int; // expected-warning {{declaration does not declare anything}} 12*f4a2713aSLionel Sambuc int : 1, : 2; 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc public: 15*f4a2713aSLionel Sambuc void m0() {}; // ok, one extra ';' is permitted 16*f4a2713aSLionel Sambuc void m1() {} 17*f4a2713aSLionel Sambuc ; // ok, one extra ';' is permitted 18*f4a2713aSLionel Sambuc void m() { 19*f4a2713aSLionel Sambuc int l = 2; 20*f4a2713aSLionel Sambuc };; // expected-warning{{extra ';' after member function definition}} 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc template<typename T> void mt(T) { } 23*f4a2713aSLionel Sambuc ; 24*f4a2713aSLionel Sambuc ; // expected-warning{{extra ';' inside a class}} 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc virtual int vf() const volatile = 0; 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc private: 29*f4a2713aSLionel Sambuc int x,f(),y,g(); 30*f4a2713aSLionel Sambuc inline int h(); 31*f4a2713aSLionel Sambuc static const int sci = 10; 32*f4a2713aSLionel Sambuc mutable int mi; 33*f4a2713aSLionel Sambuc }; 34*f4a2713aSLionel Sambuc void glo() 35*f4a2713aSLionel Sambuc { 36*f4a2713aSLionel Sambuc struct local {}; 37*f4a2713aSLionel Sambuc } 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc // PR3177 40*f4a2713aSLionel Sambuc typedef union { 41*f4a2713aSLionel Sambuc __extension__ union { 42*f4a2713aSLionel Sambuc int a; 43*f4a2713aSLionel Sambuc float b; 44*f4a2713aSLionel Sambuc } y; 45*f4a2713aSLionel Sambuc } bug3177; 46*f4a2713aSLionel Sambuc 47*f4a2713aSLionel Sambuc // check that we don't consume the token after the access specifier 48*f4a2713aSLionel Sambuc // when it's not a colon 49*f4a2713aSLionel Sambuc class D { 50*f4a2713aSLionel Sambuc public // expected-error{{expected ':'}} 51*f4a2713aSLionel Sambuc int i; 52*f4a2713aSLionel Sambuc }; 53*f4a2713aSLionel Sambuc 54*f4a2713aSLionel Sambuc // consume the token after the access specifier if it's a semicolon 55*f4a2713aSLionel Sambuc // that was meant to be a colon 56*f4a2713aSLionel Sambuc class E { 57*f4a2713aSLionel Sambuc public; // expected-error{{expected ':'}} 58*f4a2713aSLionel Sambuc int i; 59*f4a2713aSLionel Sambuc }; 60*f4a2713aSLionel Sambuc 61*f4a2713aSLionel Sambuc class F { 62*f4a2713aSLionel Sambuc int F1 { return 1; } // expected-error{{function definition does not declare parameters}} 63*f4a2713aSLionel Sambuc void F2 {} // expected-error{{function definition does not declare parameters}} 64*f4a2713aSLionel Sambuc typedef int F3() { return 0; } // expected-error{{function definition declared 'typedef'}} 65*f4a2713aSLionel Sambuc typedef void F4() {} // expected-error{{function definition declared 'typedef'}} 66*f4a2713aSLionel Sambuc }; 67*f4a2713aSLionel Sambuc 68*f4a2713aSLionel Sambuc namespace ctor_error { 69*f4a2713aSLionel Sambuc class Foo {}; 70*f4a2713aSLionel Sambuc // By [class.qual]p2, this is a constructor declaration. 71*f4a2713aSLionel Sambuc Foo::Foo (F) = F(); // expected-error{{does not match any declaration in 'ctor_error::Foo'}} 72*f4a2713aSLionel Sambuc 73*f4a2713aSLionel Sambuc class Ctor { // expected-note{{not complete until the closing '}'}} 74*f4a2713aSLionel Sambuc Ctor(f)(int); // ok 75*f4a2713aSLionel Sambuc Ctor(g(int)); // ok 76*f4a2713aSLionel Sambuc Ctor(x[5]); // expected-error{{incomplete type}} 77*f4a2713aSLionel Sambuc 78*f4a2713aSLionel Sambuc Ctor(UnknownType *); // expected-error{{unknown type name 'UnknownType'}} 79*f4a2713aSLionel Sambuc void operator+(UnknownType*); // expected-error{{unknown type name 'UnknownType'}} 80*f4a2713aSLionel Sambuc }; 81*f4a2713aSLionel Sambuc 82*f4a2713aSLionel Sambuc Ctor::Ctor (x) = { 0 }; // \ 83*f4a2713aSLionel Sambuc // expected-error{{qualified reference to 'Ctor' is a constructor name}} 84*f4a2713aSLionel Sambuc 85*f4a2713aSLionel Sambuc Ctor::Ctor(UnknownType *) {} // \ 86*f4a2713aSLionel Sambuc // expected-error{{unknown type name 'UnknownType'}} 87*f4a2713aSLionel Sambuc void Ctor::operator+(UnknownType*) {} // \ 88*f4a2713aSLionel Sambuc // expected-error{{unknown type name 'UnknownType'}} 89*f4a2713aSLionel Sambuc } 90*f4a2713aSLionel Sambuc 91*f4a2713aSLionel Sambuc namespace nns_decl { 92*f4a2713aSLionel Sambuc struct A { 93*f4a2713aSLionel Sambuc struct B; 94*f4a2713aSLionel Sambuc }; 95*f4a2713aSLionel Sambuc namespace N { 96*f4a2713aSLionel Sambuc union C; 97*f4a2713aSLionel Sambuc } 98*f4a2713aSLionel Sambuc struct A::B; // expected-error {{forward declaration of struct cannot have a nested name specifier}} 99*f4a2713aSLionel Sambuc union N::C; // expected-error {{forward declaration of union cannot have a nested name specifier}} 100*f4a2713aSLionel Sambuc } 101*f4a2713aSLionel Sambuc 102*f4a2713aSLionel Sambuc // PR13775: Don't assert here. 103*f4a2713aSLionel Sambuc namespace PR13775 { 104*f4a2713aSLionel Sambuc class bar 105*f4a2713aSLionel Sambuc { 106*f4a2713aSLionel Sambuc public: 107*f4a2713aSLionel Sambuc void foo (); 108*f4a2713aSLionel Sambuc void baz (); 109*f4a2713aSLionel Sambuc }; 110*f4a2713aSLionel Sambuc void bar::foo () 111*f4a2713aSLionel Sambuc { 112*f4a2713aSLionel Sambuc baz x(); // expected-error 3{{}} 113*f4a2713aSLionel Sambuc } 114*f4a2713aSLionel Sambuc } 115*f4a2713aSLionel Sambuc 116*f4a2713aSLionel Sambuc // PR11109 must appear at the end of the source file 117*f4a2713aSLionel Sambuc class pr11109r3 { // expected-note{{to match this '{'}} 118*f4a2713aSLionel Sambuc public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}} 119