blob: 1fbff69cb5879445f78760ce4957c9a7285b2003 [file] [log] [blame]
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00001// RUN: clang -fsyntax-only -verify %s
2class C {
3public:
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}}
7
8 static void sm() {
9 sx = 0;
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}}
12 }
13
14 class NestedC {
15 void m() {
16 sx = 0;
17 x = 0; // expected-error {{error: invalid use of nonstatic data member 'x'}}
18 }
19 };
20
21 int b : 1, w : 2;
22 int : 1, : 2;
23 typedef int E : 1; // expected-error {{error: cannot declare 'E' to be a bit-field type}}
24 static int sb : 1; // expected-error {{error: static member 'sb' cannot be a bit-field}}
25 static int vs;
26
27 typedef int func();
28 func tm;
29 func btm : 1; // expected-error {{error: bit-field 'btm' with non-integral type}}
30 NestedC bc : 1; // expected-error {{error: bit-field 'bc' with non-integral type}}
31
32 enum E { en1, en2 };
33
34 int i = 0; // expected-error {{error: 'i' can only be initialized if it is a static const integral data member}}
35 static int si = 0; // expected-error {{error: 'si' can only be initialized if it is a static const integral data member}}
36 static const NestedC ci = 0; // expected-error {{error: 'ci' can only be initialized if it is a static const integral data member}}
Chris Lattnerd8803632008-08-10 01:58:45 +000037 static const int nci = vs; // expected-error {{error: initializer element is not a compile-time constant}}
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +000038 static const int vi = 0;
39 static const E evi = 0;
40
41 void m() {
42 sx = 0;
43 this->x = 0;
44 y = 0;
45 this = 0; // expected-error {{error: expression is not assignable}}
46 }
47
48 int f1(int p) {
49 A z = 6;
50 return p + x + this->y + z;
51 }
52
53 typedef int A;
54
55private:
56 int x,y;
57 static int sx;
58};
59
60class C2 {
61 void f() {
62 static int lx;
63 class LC1 {
64 int m() { return lx; }
65 };
66 class LC2 {
67 int m() { return lx; }
68 };
69 }
70};