summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-05-26 20:19:07 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-05-26 20:19:07 +0000
commit1138ba669366ae749d487035c4bbec46a58db665 (patch)
tree015588f3bbca4a3983b48f61e6879589dd02f3df /clang/lib/Sema/SemaDeclCXX.cpp
parent1b08572a665402ce57771507b3bcbe235ff1ba82 (diff)
downloadbcm5719-llvm-1138ba669366ae749d487035c4bbec46a58db665.tar.gz
bcm5719-llvm-1138ba669366ae749d487035c4bbec46a58db665.zip
Fixes misc. flexible array bugs in c++ (PR7029).
llvm-svn: 104733
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 29fb6d6eac4..148d1463c20 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1892,9 +1892,15 @@ Sema::SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
// Fields.
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
- E = ClassDecl->field_end(); Field != E; ++Field)
+ E = ClassDecl->field_end(); Field != E; ++Field) {
+ if ((*Field)->getType()->isIncompleteArrayType()) {
+ assert(ClassDecl->hasFlexibleArrayMember() &&
+ "Incomplete array type is not valid");
+ continue;
+ }
if (CollectFieldInitializer(Info, *Field, *Field))
HadError = true;
+ }
NumInitializers = Info.AllToInit.size();
if (NumInitializers > 0) {
@@ -4577,6 +4583,11 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
}
QualType FieldType = Field->getType().getNonReferenceType();
+ if (FieldType->isIncompleteArrayType()) {
+ assert(ClassDecl->hasFlexibleArrayMember() &&
+ "Incomplete array type is not valid");
+ continue;
+ }
// Build references to the field in the object we're copying from and to.
CXXScopeSpec SS; // Intentionally empty
OpenPOWER on IntegriCloud