forked from OSchip/llvm-project
Clarify the diagnostic for -Wnested-anon-types.
llvm-svn: 174032
This commit is contained in:
parent
9a6d4f3644
commit
d202924db6
|
|
@ -5351,8 +5351,8 @@ def ext_anonymous_record_with_type : Extension<
|
||||||
"types declared in an anonymous %select{struct|union}0 are a Microsoft "
|
"types declared in an anonymous %select{struct|union}0 are a Microsoft "
|
||||||
"extension">, InGroup<Microsoft>;
|
"extension">, InGroup<Microsoft>;
|
||||||
def ext_anonymous_record_with_anonymous_type : Extension<
|
def ext_anonymous_record_with_anonymous_type : Extension<
|
||||||
"nested anonymous types are an extension">,
|
"anonymous types declared in an anonymous %select{struct|union}0 "
|
||||||
InGroup<DiagGroup<"nested-anon-types">>;
|
"are an extension">, InGroup<DiagGroup<"nested-anon-types">>;
|
||||||
def err_anonymous_record_with_function : Error<
|
def err_anonymous_record_with_function : Error<
|
||||||
"functions cannot be declared in an anonymous %select{struct|union}0">;
|
"functions cannot be declared in an anonymous %select{struct|union}0">;
|
||||||
def err_anonymous_record_with_static : Error<
|
def err_anonymous_record_with_static : Error<
|
||||||
|
|
|
||||||
|
|
@ -3242,7 +3242,8 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
||||||
// This is a popular extension, provided by Plan9, MSVC and GCC, but
|
// This is a popular extension, provided by Plan9, MSVC and GCC, but
|
||||||
// not part of standard C++.
|
// not part of standard C++.
|
||||||
Diag(MemRecord->getLocation(),
|
Diag(MemRecord->getLocation(),
|
||||||
diag::ext_anonymous_record_with_anonymous_type);
|
diag::ext_anonymous_record_with_anonymous_type)
|
||||||
|
<< (int)Record->isUnion();
|
||||||
}
|
}
|
||||||
} else if (isa<AccessSpecDecl>(*Mem)) {
|
} else if (isa<AccessSpecDecl>(*Mem)) {
|
||||||
// Any access specifier is fine.
|
// Any access specifier is fine.
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ struct X {
|
||||||
int i;
|
int i;
|
||||||
float f;
|
float f;
|
||||||
|
|
||||||
union { // expected-warning{{nested anonymous types are an extension}}
|
union { // expected-warning{{anonymous types declared in an anonymous union are an extension}}
|
||||||
float f2;
|
float f2;
|
||||||
mutable double d;
|
mutable double d;
|
||||||
};
|
};
|
||||||
|
|
@ -101,7 +101,7 @@ void g() {
|
||||||
struct BadMembers {
|
struct BadMembers {
|
||||||
union {
|
union {
|
||||||
struct X { }; // expected-error {{types cannot be declared in an anonymous union}}
|
struct X { }; // expected-error {{types cannot be declared in an anonymous union}}
|
||||||
struct { int x; int y; } y; // expected-warning{{nested anonymous types are an extension}}
|
struct { int x; int y; } y; // expected-warning{{anonymous types declared in an anonymous union are an extension}}
|
||||||
|
|
||||||
void f(); // expected-error{{functions cannot be declared in an anonymous union}}
|
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}}
|
private: int x1; // expected-error{{anonymous union cannot contain a private data member}}
|
||||||
|
|
@ -128,7 +128,7 @@ namespace test4 {
|
||||||
struct { // expected-warning{{anonymous structs are a GNU extension}}
|
struct { // expected-warning{{anonymous structs are a GNU extension}}
|
||||||
int s0; // expected-note {{declared private here}}
|
int s0; // expected-note {{declared private here}}
|
||||||
double s1; // expected-note {{declared private here}}
|
double s1; // expected-note {{declared private here}}
|
||||||
union { // expected-warning{{nested anonymous type}}
|
union { // expected-warning{{anonymous types declared in an anonymous struct are an extension}}
|
||||||
int su0; // expected-note {{declared private here}}
|
int su0; // expected-note {{declared private here}}
|
||||||
double su1; // expected-note {{declared private here}}
|
double su1; // expected-note {{declared private here}}
|
||||||
};
|
};
|
||||||
|
|
@ -136,7 +136,7 @@ namespace test4 {
|
||||||
union {
|
union {
|
||||||
int u0; // expected-note {{declared private here}}
|
int u0; // expected-note {{declared private here}}
|
||||||
double u1; // expected-note {{declared private here}}
|
double u1; // expected-note {{declared private here}}
|
||||||
struct { // expected-warning{{anonymous structs are a GNU extension}} expected-warning{{nested anonymous type}}
|
struct { // expected-warning{{anonymous structs are a GNU extension}} expected-warning{{anonymous types declared in an anonymous union are an extension}}
|
||||||
int us0; // expected-note {{declared private here}}
|
int us0; // expected-note {{declared private here}}
|
||||||
double us1; // expected-note {{declared private here}}
|
double us1; // expected-note {{declared private here}}
|
||||||
};
|
};
|
||||||
|
|
@ -187,7 +187,7 @@ namespace PR8326 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const union { // expected-warning{{anonymous union cannot be 'const'}}
|
const union { // expected-warning{{anonymous union cannot be 'const'}}
|
||||||
struct { // expected-warning{{anonymous structs are a GNU extension}} expected-warning{{nested anonymous type}}
|
struct { // expected-warning{{anonymous structs are a GNU extension}} expected-warning{{declared in an anonymous union}}
|
||||||
T x;
|
T x;
|
||||||
T y;
|
T y;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1153,8 +1153,8 @@ namespace ConvertedConstantExpr {
|
||||||
namespace IndirectField {
|
namespace IndirectField {
|
||||||
struct S {
|
struct S {
|
||||||
struct { // expected-warning {{GNU extension}}
|
struct { // expected-warning {{GNU extension}}
|
||||||
union { // expected-warning {{nested anonymous types are an extension}}
|
union { // expected-warning {{declared in an anonymous struct}}
|
||||||
struct { // expected-warning {{GNU extension}} expected-warning {{nested anonymous types are an extension}}
|
struct { // expected-warning {{GNU extension}} expected-warning {{declared in an anonymous union}}
|
||||||
int a;
|
int a;
|
||||||
int b;
|
int b;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue