blob: 75e3fbacc46c72bdfacbb02aeec28e70c27838f1 [file] [log] [blame]
Douglas Gregor9ea416e2011-01-19 16:41:58 +00001// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
Sebastian Redlab963c62008-11-08 15:40:37 +00002class C;
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +00003class C {
4public:
5protected:
6 typedef int A,B;
7 static int sf(), u;
8
9 struct S {};
Douglas Gregora131d0f2010-07-13 06:24:26 +000010 enum {}; // expected-warning{{declaration does not declare anything}}
Douglas Gregorcb821d02010-04-08 21:33:23 +000011 int; // expected-warning {{declaration does not declare anything}}
Argyrios Kyrtzidis3a9fdb42008-06-28 08:10:48 +000012 int : 1, : 2;
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000013
14public:
15 void m() {
16 int l = 2;
Richard Trieu4b0e6f12012-05-16 19:04:59 +000017 }; // expected-warning{{extra ';' after function definition}}
Douglas Gregor9ea416e2011-01-19 16:41:58 +000018
Richard Trieu4b0e6f12012-05-16 19:04:59 +000019 template<typename T> void mt(T) { }
Douglas Gregor9ea416e2011-01-19 16:41:58 +000020 ; // expected-warning{{extra ';' inside a class}}
21
Sebastian Redlab963c62008-11-08 15:40:37 +000022 virtual int vf() const volatile = 0;
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000023
24private:
25 int x,f(),y,g();
Sebastian Redlab963c62008-11-08 15:40:37 +000026 inline int h();
27 static const int sci = 10;
Sebastian Redl669d5d72008-11-14 23:42:31 +000028 mutable int mi;
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000029};
Sebastian Redlab963c62008-11-08 15:40:37 +000030void glo()
31{
32 struct local {};
33}
Chris Lattnerbc8d5642008-12-18 01:12:00 +000034
35// PR3177
36typedef union {
37 __extension__ union {
38 int a;
39 float b;
40 } y;
41} bug3177;
42
David Blaikie13f8daf2011-10-13 06:08:43 +000043// check that we don't consume the token after the access specifier
44// when it's not a colon
45class D {
46public // expected-error{{expected ':'}}
47 int i;
48};
49
50// consume the token after the access specifier if it's a semicolon
51// that was meant to be a colon
52class E {
53public; // expected-error{{expected ':'}}
54 int i;
55};
56
Richard Trieu65ba9482012-01-21 02:59:18 +000057class F {
58 int F1 { return 1; } // expected-error{{function definition does not declare parameters}}
59 void F2 {} // expected-error{{function definition does not declare parameters}}
60 typedef int F3() { return 0; } // expected-error{{function definition declared 'typedef'}}
61 typedef void F4() {} // expected-error{{function definition declared 'typedef'}}
62};
63
Richard Smith412e0cc2012-03-27 00:56:56 +000064namespace ctor_error {
65 class Foo {};
66 // By [class.qual]p2, this is a constructor declaration.
67 Foo::Foo (F) = F(); // expected-error{{does not match any declaration in 'ctor_error::Foo'}}
68
69 class Ctor { // expected-note{{not complete until the closing '}'}}
70 Ctor(f)(int); // ok
71 Ctor(g(int)); // ok
72 Ctor(x[5]); // expected-error{{incomplete type}}
73
74 Ctor(UnknownType *); // expected-error{{unknown type name 'UnknownType'}}
Richard Smith52f10d52012-03-29 01:46:00 +000075 void operator+(UnknownType*); // expected-error{{unknown type name 'UnknownType'}}
Richard Smith412e0cc2012-03-27 00:56:56 +000076 };
77
78 Ctor::Ctor (x) = { 0 }; // \
79 // expected-error{{qualified reference to 'Ctor' is a constructor name}}
80
Richard Smith412e0cc2012-03-27 00:56:56 +000081 Ctor::Ctor(UnknownType *) {} // \
Richard Smith52f10d52012-03-29 01:46:00 +000082 // expected-error{{unknown type name 'UnknownType'}}
83 void Ctor::operator+(UnknownType*) {} // \
84 // expected-error{{unknown type name 'UnknownType'}}
Richard Smith412e0cc2012-03-27 00:56:56 +000085}
86
David Blaikie13f8daf2011-10-13 06:08:43 +000087// PR11109 must appear at the end of the source file
88class pr11109r3 { // expected-note{{to match this '{'}}
89 public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}