The declaration of a flexible array member was correctly diagnosed as an
extension in C89 mode but not in C++.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193918
91177308-0d34-0410-b5e6-
96231b3b80d8
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>;
+ "flexible array members are a C99-specific feature">, InGroup<C99>;
def ext_enumerator_list_comma_c : Extension<
"commas at the end of enumerator lists are a C99-specific "
"feature">, InGroup<C99>;
else if (Fields.size() == 1)
Diag(FD->getLocation(), diag::ext_flexible_array_empty_aggregate_ms)
<< FD->getDeclName() << Record->getTagKind();
+ else
+ Diag(FD->getLocation(), diag::ext_c99_flexible_array_member)
+ << FD->getDeclName() << Record->getTagKind();
} else if (getLangOpts().CPlusPlus) {
if (Record->isUnion())
Diag(FD->getLocation(), diag::ext_flexible_array_union_gnu)
else if (Fields.size() == 1)
Diag(FD->getLocation(), diag::ext_flexible_array_empty_aggregate_gnu)
<< FD->getDeclName() << Record->getTagKind();
+ else
+ Diag(FD->getLocation(), diag::ext_c99_flexible_array_member)
+ << FD->getDeclName() << Record->getTagKind();
} else if (!getLangOpts().C99) {
if (Record->isUnion())
Diag(FD->getLocation(), diag::ext_flexible_array_union_gnu)
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}} */
+struct x { int x,y[]; }; /* expected-warning {{flexible array members are a C99-specific feature}} */
/* Duplicated type-qualifiers aren't allowed by C90 */
const const int c_i; /* expected-warning {{duplicate 'const' declaration specifier}} */
void f1(int i[static 5]) { // expected-error{{C99}}
}
-struct Point { int x; int y; };
+struct Point { int x; int y; int z[]; }; // expected-warning{{flexible array members are a C99-specific feature}}
Point p1 = { .x = 17, // expected-warning{{designated initializers are a C99 feature}}
y: 25 }; // expected-warning{{designated initializers are a C99 feature}} \