1 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
12 union { // expected-warning{{anonymous types declared in an anonymous union are an extension}}
18 void test_unqual_references();
20 struct { // expected-warning{{anonymous structs are a GNU extension}}
25 void test_unqual_references_const() const;
27 mutable union { // expected-error{{anonymous union at class scope must not have a storage specifier}}
33 void X::test_unqual_references() {
38 f3 = 0; // expected-error{{use of undeclared identifier 'f3'}}
42 void X::test_unqual_references_const() const {
44 f2 = 0; // expected-error{{read-only variable is not assignable}}
45 a = 0; // expected-error{{read-only variable is not assignable}}
48 void test_unqual_references(X x, const X xc) {
53 x.f3 = 0; // expected-error{{no member named 'f3'}}
57 xc.f = 0; // expected-error{{read-only variable is not assignable}}
58 xc.a = 0; // expected-error{{read-only variable is not assignable}}
63 int x; // expected-note{{previous declaration is here}}
67 int x; // expected-error{{member of anonymous union redeclares 'x'}}
69 double z; // expected-note{{previous declaration is here}}
70 double zz; // expected-note{{previous definition is here}}
73 int z; // expected-error{{duplicate member 'z'}}
74 void zz(); // expected-error{{redefinition of 'zz' as different kind of symbol}}
77 union { // expected-error{{anonymous unions at namespace or global scope must be declared 'static'}}
103 struct X { }; // expected-error {{types cannot be declared in an anonymous union}}
104 struct { int x; int y; } y; // expected-warning{{anonymous types declared in an anonymous union are an extension}}
106 void f(); // expected-error{{functions cannot be declared in an anonymous union}}
107 private: int x1; // expected-error{{anonymous union cannot contain a private data member}}
108 protected: float x2; // expected-error{{anonymous union cannot contain a protected data member}}
112 // <rdar://problem/6481130>
113 typedef union { }; // expected-warning{{typedef requires a name}}
115 // <rdar://problem/7562438>
116 typedef struct objc_module *Foo ;
125 // <rdar://problem/7987650>
128 struct { // expected-warning{{anonymous structs are a GNU extension}}
129 int s0; // expected-note {{declared private here}}
130 double s1; // expected-note {{declared private here}}
131 union { // expected-warning{{anonymous types declared in an anonymous struct are an extension}}
132 int su0; // expected-note {{declared private here}}
133 double su1; // expected-note {{declared private here}}
137 int u0; // expected-note {{declared private here}}
138 double u1; // expected-note {{declared private here}}
139 struct { // expected-warning{{anonymous structs are a GNU extension}} expected-warning{{anonymous types declared in an anonymous union are an extension}}
140 int us0; // expected-note {{declared private here}}
141 double us1; // expected-note {{declared private here}}
148 (void) a.s0; // expected-error {{private member}}
149 (void) a.s1; // expected-error {{private member}}
150 (void) a.su0; // expected-error {{private member}}
151 (void) a.su1; // expected-error {{private member}}
152 (void) a.u0; // expected-error {{private member}}
153 (void) a.u1; // expected-error {{private member}}
154 (void) a.us0; // expected-error {{private member}}
155 (void) a.us1; // expected-error {{private member}}
159 typedef void *voidPtr;
162 union { int **ctxPtr; void **voidPtr; };
189 const union { // expected-warning{{anonymous union cannot be 'const'}}
190 struct { // expected-warning{{anonymous structs are a GNU extension}} expected-warning{{declared in an anonymous union}}
202 struct A { union { int x; float y; }; }; // expected-note {{member is declared here}}
203 struct B : private A { using A::x; } b; // expected-note 2 {{private}}
206 b.y = 0; // expected-error {{cannot cast 'struct B' to its private base class 'PR16630::A'}} expected-error {{'y' is a private member of 'PR16630::A'}}