1 // RUN: %clang_cc1 -fsyntax-only -verify %s
4 auto int errx; // expected-error {{error: storage class specified for a member declaration}}
5 register int erry; // expected-error {{error: storage class specified for a member declaration}}
6 extern int errz; // expected-error {{error: storage class specified for a member declaration}}
10 this->x = 0; // expected-error {{error: invalid use of 'this' outside of a nonstatic member function}}
11 x = 0; // expected-error {{error: invalid use of member 'x' in static member function}}
17 x = 0; // expected-error {{error: invalid use of nonstatic data member 'x'}}
23 typedef int E : 1; // expected-error {{typedef member 'E' cannot be a bit-field}}
24 static int sb : 1; // expected-error {{error: static member 'sb' cannot be a bit-field}}
30 func btm : 1; // expected-error {{bit-field 'btm' has non-integral type}}
31 NestedC bc : 1; // expected-error {{bit-field 'bc' has non-integral type}}
35 int i = 0; // expected-error {{error: 'i' can only be initialized if it is a static const integral data member}}
36 static int si = 0; // expected-error {{error: 'si' can only be initialized if it is a static const integral data member}}
37 static const NestedC ci = 0; // expected-error {{error: 'ci' can only be initialized if it is a static const integral data member}}
38 static const int nci = vs; // expected-error {{in-class initializer is not an integral constant expression}}
39 static const int vi = 0;
40 static const E evi = 0;
46 this = 0; // expected-error {{error: expression is not assignable}}
51 return p + x + this->y + z;
56 virtual int viv; // expected-error {{'virtual' can only appear on non-static member functions}}
57 virtual static int vsif(); // expected-error {{error: 'virtual' can only appear on non-static member functions}}
65 mutable int &mir; // expected-error {{error: 'mutable' cannot be applied to references}}
66 mutable void mfn(); // expected-error {{error: 'mutable' cannot be applied to functions}}
67 mutable const int mci; // expected-error {{error: 'mutable' and 'const' cannot be mixed}}
69 static const int number = 50;
70 static int arr[number];
77 int m() { return lx; }
80 int m() { return lx; }
91 const C3 c3 = { 1, 2 };
92 (void)static_cast<int*>(&c3.i); // expected-error {{static_cast from 'int const *' to 'int *' is not allowed}}
94 (void)static_cast<int*>(&c3.j);
97 // Play with mutable a bit more, to make sure it doesn't crash anything.
98 mutable int gi; // expected-error {{error: 'mutable' can only be applied to member variables}}
99 mutable void gfn(); // expected-error {{illegal storage class on function}}
102 mutable int ml; // expected-error {{error: 'mutable' can only be applied to member variables}}
104 // PR3020: This used to crash due to double ownership of C4.
106 C4; // expected-error {{declaration does not declare anything}}
110 void f(); // expected-note{{previous declaration is here}}
111 int f; // expected-error{{duplicate member 'f'}}
114 // PR5415 - don't hang!
117 void f(); // expected-note 1 {{previous declaration}}
118 void S::f() {} // expected-error {{class member cannot be redeclared}} expected-note {{previous declaration}} expected-note {{previous definition}}
119 void f() {} // expected-error {{class member cannot be redeclared}} expected-error {{redefinition}}