def ext_anonymous_record_with_type : Extension<
"types declared in an anonymous %select{struct|union}0 are a Microsoft "
"extension">, InGroup<Microsoft>;
+def ext_anonymous_record_with_anonymous_type : Extension<
+ "nested anonymous types are an extension">,
+ InGroup<DiagGroup<"nested-anon-types">>;
def err_anonymous_record_with_function : Error<
"functions cannot be declared in an anonymous %select{struct|union}0">;
def err_anonymous_record_with_static : Error<
<< (int)Record->isUnion();
Invalid = true;
}
+ } else {
+ // This is an anonymous type definition within another anonymous type.
+ // This is a popular extension, provided by Plan9, MSVC and GCC, but
+ // not part of standard C++.
+ Diag(MemRecord->getLocation(),
+ diag::ext_anonymous_record_with_anonymous_type);
}
} else if (isa<AccessSpecDecl>(*Mem)) {
// Any access specifier is fine.
int i;
float f;
- union {
+ union { // expected-warning{{nested anonymous types are an extension}}
float f2;
mutable double d;
};
struct BadMembers {
union {
struct X { }; // expected-error {{types cannot be declared in an anonymous union}}
- struct { int x; int y; } y;
+ struct { int x; int y; } y; // expected-warning{{nested anonymous types are an extension}}
void f(); // expected-error{{functions cannot be declared in an anonymous union}}
private: int x1; // expected-error{{anonymous union cannot contain a private data member}}
struct { // expected-warning{{anonymous structs are a GNU extension}}
int s0; // expected-note {{declared private here}}
double s1; // expected-note {{declared private here}}
- union {
+ union { // expected-warning{{nested anonymous type}}
int su0; // expected-note {{declared private here}}
double su1; // expected-note {{declared private here}}
};
union {
int u0; // expected-note {{declared private here}}
double u1; // expected-note {{declared private here}}
- struct { // expected-warning{{anonymous structs are a GNU extension}}
+ struct { // expected-warning{{anonymous structs are a GNU extension}} expected-warning{{nested anonymous type}}
int us0; // expected-note {{declared private here}}
double us1; // expected-note {{declared private here}}
};
private:
const union { // expected-warning{{anonymous union cannot be 'const'}}
- struct { // expected-warning{{anonymous structs are a GNU extension}}
+ struct { // expected-warning{{anonymous structs are a GNU extension}} expected-warning{{nested anonymous type}}
T x;
T y;
};
namespace IndirectField {
struct S {
struct { // expected-warning {{GNU extension}}
- union {
- struct { // expected-warning {{GNU extension}}
+ union { // expected-warning {{nested anonymous types are an extension}}
+ struct { // expected-warning {{GNU extension}} expected-warning {{nested anonymous types are an extension}}
int a;
int b;
};