mirror of
https://github.com/intel/llvm.git
synced 2026-01-23 07:58:23 +08:00
Warn on flexible array members when in C89 mode, with -pedantic.
This fixes PR 4307. Patch by Eitan Adler! llvm-svn: 152918
This commit is contained in:
@@ -56,6 +56,8 @@ def ext_c99_variable_decl_in_for_loop : Extension<
|
||||
"variable declaration in for loop is a C99-specific feature">, InGroup<C99>;
|
||||
def ext_c99_compound_literal : Extension<
|
||||
"compound literals are a C99-specific feature">, InGroup<C99>;
|
||||
def ext_c99_flexible_array_member : Extension<
|
||||
"Flexible array members are a C99-specific feature">, InGroup<C99>;
|
||||
def ext_enumerator_list_comma : Extension<
|
||||
"commas at the end of enumerator lists are a %select{C99|C++11}0-specific "
|
||||
"feature">;
|
||||
|
||||
@@ -9483,6 +9483,13 @@ void Sema::ActOnFields(Scope* S,
|
||||
else if (Fields.size() == 1)
|
||||
Diag(FD->getLocation(), diag::ext_flexible_array_empty_aggregate_gnu)
|
||||
<< FD->getDeclName() << Record->getTagKind();
|
||||
} else if (!getLangOpts().C99) {
|
||||
if (Record->isUnion())
|
||||
Diag(FD->getLocation(), diag::ext_flexible_array_union_gnu)
|
||||
<< FD->getDeclName();
|
||||
else
|
||||
Diag(FD->getLocation(), diag::ext_c99_flexible_array_member)
|
||||
<< FD->getDeclName() << Record->getTagKind();
|
||||
} else if (NumNamedMembers < 1) {
|
||||
Diag(FD->getLocation(), diag::err_flexible_array_empty_struct)
|
||||
<< FD->getDeclName();
|
||||
|
||||
@@ -90,4 +90,6 @@ void test16() {
|
||||
printg("Hello, world!\n"); /* expected-warning {{implicit declaration of function 'printg'}} */
|
||||
}
|
||||
|
||||
struct x { int x,y[]; }; /* expected-warning {{Flexible array members are a C99-specific feature}} */
|
||||
|
||||
void main() {} /* expected-error {{'main' must return 'int'}} */
|
||||
|
||||
Reference in New Issue
Block a user