forked from OSchip/llvm-project
Downgrade complaints about the use of variable-sized types within a
struct to an extension warning to match the behavior of GNU C, which addresses the Sema part of PR3671. llvm-svn: 66308
This commit is contained in:
parent
5f080b43fa
commit
3e06dbf48c
|
@ -774,8 +774,9 @@ DIAG(err_field_declared_as_function, ERROR,
|
|||
"field %0 declared as a function")
|
||||
DIAG(err_field_incomplete, ERROR,
|
||||
"field has incomplete type %0")
|
||||
DIAG(err_variable_sized_type_in_struct, ERROR,
|
||||
"variable sized type %0 must be at end of struct or class")
|
||||
DIAG(ext_variable_sized_type_in_struct, EXTWARN,
|
||||
"variable sized type %0 not at the end of a struct or class is a "
|
||||
"GNU extension")
|
||||
DIAG(err_flexible_array_empty_struct, ERROR,
|
||||
"flexible array %0 not allowed in otherwise empty struct")
|
||||
DIAG(ext_flexible_array_in_struct, EXTENSION,
|
||||
|
|
|
@ -3525,19 +3525,17 @@ void Sema::ActOnFields(Scope* S,
|
|||
// If this is a struct/class and this is not the last element, reject
|
||||
// it. Note that GCC supports variable sized arrays in the middle of
|
||||
// structures.
|
||||
if (i != NumFields-1) {
|
||||
Diag(FD->getLocation(), diag::err_variable_sized_type_in_struct)
|
||||
if (i != NumFields-1)
|
||||
Diag(FD->getLocation(), diag::ext_variable_sized_type_in_struct)
|
||||
<< FD->getDeclName();
|
||||
FD->setInvalidDecl();
|
||||
EnclosingDecl->setInvalidDecl();
|
||||
continue;
|
||||
else {
|
||||
// We support flexible arrays at the end of structs in
|
||||
// other structs as an extension.
|
||||
Diag(FD->getLocation(), diag::ext_flexible_array_in_struct)
|
||||
<< FD->getDeclName();
|
||||
if (Record)
|
||||
Record->setHasFlexibleArrayMember(true);
|
||||
}
|
||||
// We support flexible arrays at the end of structs in other structs
|
||||
// as an extension.
|
||||
Diag(FD->getLocation(), diag::ext_flexible_array_in_struct)
|
||||
<< FD->getDeclName();
|
||||
if (Record)
|
||||
Record->setHasFlexibleArrayMember(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ int foo() {
|
|||
return f->v + f[0].v;
|
||||
}
|
||||
|
||||
// PR3642
|
||||
// PR3642, PR3671
|
||||
struct pppoe_tag {
|
||||
short tag_type;
|
||||
char tag_data[];
|
||||
};
|
||||
struct datatag {
|
||||
struct pppoe_tag hdr; //expected-error{{variable sized type 'hdr' must be at end of struct}}
|
||||
struct pppoe_tag hdr; //expected-warning{{variable sized type 'hdr' not at the end of a struct or class is a GNU extension}}
|
||||
char data;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue