forked from OSchip/llvm-project
Reword the empty struct/union warning in C to note that such structs and unions have size 0 in C, size 1 in C++. Put this warning under -Wc++-compat.
llvm-svn: 109748
This commit is contained in:
parent
07035e6a00
commit
da2955ed74
|
@ -25,7 +25,7 @@ def AmbigMemberTemplate : DiagGroup<"ambiguous-member-template">;
|
|||
def : DiagGroup<"attributes">;
|
||||
def : DiagGroup<"bad-function-cast">;
|
||||
def BoolConversions : DiagGroup<"bool-conversions">;
|
||||
def : DiagGroup<"c++-compat">;
|
||||
def CXXCompat: DiagGroup<"c++-compat">;
|
||||
def : DiagGroup<"cast-align">;
|
||||
def : DiagGroup<"cast-qual">;
|
||||
def : DiagGroup<"char-align">;
|
||||
|
|
|
@ -35,8 +35,9 @@ def ext_integer_complex : Extension<
|
|||
"complex integer types are an extension">;
|
||||
def ext_thread_before : Extension<"'__thread' before 'static'">;
|
||||
|
||||
def ext_empty_struct_union_enum : Extension<"use of empty %0 extension">;
|
||||
|
||||
def ext_empty_struct_union : Extension<"empty %select{struct|union}0 "
|
||||
"(accepted as an extension) has size 0 in C, size 1 in C++">,
|
||||
InGroup<CXXCompat>;
|
||||
def error_empty_enum : Error<"use of empty enum">;
|
||||
def err_invalid_sign_spec : Error<"'%0' cannot be signed or unsigned">;
|
||||
def err_invalid_short_spec : Error<"'short %0' is invalid">;
|
||||
|
|
|
@ -1782,8 +1782,8 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
|
|||
// Empty structs are an extension in C (C99 6.7.2.1p7), but are allowed in
|
||||
// C++.
|
||||
if (Tok.is(tok::r_brace) && !getLang().CPlusPlus)
|
||||
Diag(Tok, diag::ext_empty_struct_union_enum)
|
||||
<< DeclSpec::getSpecifierName((DeclSpec::TST)TagType);
|
||||
Diag(Tok, diag::ext_empty_struct_union)
|
||||
<< (TagType == TST_union);
|
||||
|
||||
llvm::SmallVector<DeclPtrTy, 32> FieldDecls;
|
||||
|
||||
|
|
|
@ -218,7 +218,8 @@ void varArray() {
|
|||
}
|
||||
|
||||
// PR2151
|
||||
void emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct extension}} expected-error{{initializer for aggregate with no elements}}
|
||||
void emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct (accepted as an extension) has size 0 in C, size 1 in C++}} \
|
||||
// expected-error{{initializer for aggregate with no elements}}
|
||||
|
||||
void noNamedInit() {
|
||||
struct {int:5;} x[] = {6}; //expected-error{{initializer for aggregate with no elements}}
|
||||
|
@ -241,7 +242,8 @@ struct soft_segment_descriptor gdt_segs[] = {
|
|||
};
|
||||
|
||||
static void sppp_ipv6cp_up();
|
||||
const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct extension}} expected-warning{{excess elements in struct initializer}}
|
||||
const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct (accepted as an extension) has size 0 in C, size 1 in C++}} \
|
||||
// expected-warning{{excess elements in struct initializer}}
|
||||
|
||||
struct _Matrix { union { float m[4][4]; }; }; //expected-warning{{anonymous unions are a GNU extension in C}}
|
||||
typedef struct _Matrix Matrix;
|
||||
|
|
|
@ -11,7 +11,7 @@ static int x = (int){1};
|
|||
static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not a compile-time constant}}
|
||||
static long *p3 = (long []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [2]'}}
|
||||
|
||||
typedef struct { } cache_t; // -expected-warning{{use of empty struct extension}}
|
||||
typedef struct { } cache_t; // -expected-warning{{empty struct (accepted as an extension) has size 0 in C, size 1 in C++}}
|
||||
static cache_t clo_I1_cache = ((cache_t) { } ); // -expected-warning{{use of GNU empty initializer extension}}
|
||||
|
||||
typedef struct Test {int a;int b;} Test;
|
||||
|
|
Loading…
Reference in New Issue