[cfe-commits] r113018 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/flexible-array-test.cpp
Anders Carlsson
andersca at mac.com
Fri Sep 3 14:53:49 PDT 2010
Author: andersca
Date: Fri Sep 3 16:53:49 2010
New Revision: 113018
URL: http://llvm.org/viewvc/llvm-project?rev=113018&view=rev
Log:
It's OK for classes to have flexible array elements (but not unions).
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/flexible-array-test.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=113018&r1=113017&r2=113018&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Sep 3 16:53:49 2010
@@ -6564,7 +6564,7 @@
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)
Modified: cfe/trunk/test/SemaCXX/flexible-array-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/flexible-array-test.cpp?rev=113018&r1=113017&r2=113018&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/flexible-array-test.cpp (original)
+++ cfe/trunk/test/SemaCXX/flexible-array-test.cpp Fri Sep 3 16:53:49 2010
@@ -43,3 +43,13 @@
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 []'}}
+};
More information about the cfe-commits
mailing list