forked from OSchip/llvm-project
[Sema] A flexible array member must not be the only named member
We didn't correctly detect situations where a flexible array member was the only named member in a record. This fixes PR28407. llvm-svn: 274477
This commit is contained in:
parent
c804751a18
commit
3b568aa4ed
|
@ -13952,14 +13952,12 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
|
|||
: getLangOpts().CPlusPlus
|
||||
? diag::ext_flexible_array_union_gnu
|
||||
: diag::err_flexible_array_union;
|
||||
else if (Fields.size() == 1)
|
||||
else if (NumNamedMembers < 1)
|
||||
DiagID = getLangOpts().MicrosoftExt
|
||||
? diag::ext_flexible_array_empty_aggregate_ms
|
||||
: getLangOpts().CPlusPlus
|
||||
? diag::ext_flexible_array_empty_aggregate_gnu
|
||||
: NumNamedMembers < 1
|
||||
? diag::err_flexible_array_empty_aggregate
|
||||
: 0;
|
||||
: diag::err_flexible_array_empty_aggregate;
|
||||
|
||||
if (DiagID)
|
||||
Diag(FD->getLocation(), DiagID) << FD->getDeclName()
|
||||
|
|
|
@ -6,6 +6,12 @@ struct A
|
|||
int a[]; /* expected-warning {{flexible array member 'a' in otherwise empty struct is a Microsoft extension}} */
|
||||
};
|
||||
|
||||
struct PR28407
|
||||
{
|
||||
int : 1;
|
||||
int a[]; /* expected-warning {{flexible array member 'a' in otherwise empty struct is a Microsoft extension}} */
|
||||
};
|
||||
|
||||
struct C {
|
||||
int l;
|
||||
union {
|
||||
|
|
Loading…
Reference in New Issue