summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-09-03 21:53:49 +0000
committerAnders Carlsson <andersca@mac.com>2010-09-03 21:53:49 +0000
commitf849774495503e3a53b31bdbaf813f5bc3c0d92a (patch)
tree8b0f7e66d9be27222db2b29e2893e781b762c352
parentb77c0c03bb5f48c7ff98aa0d8dd5c648e8a1a651 (diff)
downloadbcm5719-llvm-f849774495503e3a53b31bdbaf813f5bc3c0d92a.tar.gz
bcm5719-llvm-f849774495503e3a53b31bdbaf813f5bc3c0d92a.zip
It's OK for classes to have flexible array elements (but not unions).
llvm-svn: 113018
-rw-r--r--clang/lib/Sema/SemaDecl.cpp2
-rw-r--r--clang/test/SemaCXX/flexible-array-test.cpp10
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 35515183163..f5e045a722a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6564,7 +6564,7 @@ void Sema::ActOnFields(Scope* S,
EnclosingDecl->setInvalidDecl();
continue;
} else if (FDTy->isIncompleteArrayType() && i == NumFields - 1 &&
- Record && Record->isStruct()) {
+ Record && !Record->isUnion()) {
// Flexible array member.
if (NumNamedMembers < 1) {
Diag(FD->getLocation(), diag::err_flexible_array_empty_struct)
diff --git a/clang/test/SemaCXX/flexible-array-test.cpp b/clang/test/SemaCXX/flexible-array-test.cpp
index 02e3f83974e..95d8bb1aa41 100644
--- a/clang/test/SemaCXX/flexible-array-test.cpp
+++ b/clang/test/SemaCXX/flexible-array-test.cpp
@@ -43,3 +43,13 @@ struct X {
int blah;
S strings[]; // expected-error {{flexible array member 'strings' of non-POD element type 'S []'}}
};
+
+class A {
+ int s;
+ char c[];
+};
+
+union B {
+ int s;
+ char c[]; // expected-error {{field has incomplete type 'char []'}}
+};
OpenPOWER on IntegriCloud