aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDavid Chisnall <csdavec@swan.ac.uk>2012-03-16 12:15:37 +0000
committerDavid Chisnall <csdavec@swan.ac.uk>2012-03-16 12:15:37 +0000
commit0961a01ebec0e31664bfe464bf4a0ac7b0891a1f (patch)
tree99f3e36f6dc5c7ceb3b343d5ccbc404d2cad4214 /lib/Sema/SemaDecl.cpp
parente55329d6834647ba0e06f8a319e5d84c77310035 (diff)
Warn on flexible array members when in C89 mode, with -pedantic.
This fixes PR 4307. Patch by Eitan Adler! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index ab1a1b4025..574c18c2e3 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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();