summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-09-28 21:23:50 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-09-28 21:23:50 +0000
commit845aa66a8a51d6750a8d461b062026fcc19164d3 (patch)
tree38560a6b742c94c03f80a594df81f114889ce446
parent8c6b06d4a07659fb0a3647456961095a31568199 (diff)
downloadbcm5719-llvm-845aa66a8a51d6750a8d461b062026fcc19164d3.tar.gz
bcm5719-llvm-845aa66a8a51d6750a8d461b062026fcc19164d3.zip
When processing an InitListExpr and skipping the initialization of an invalid
record, skip at least one element from the InitListExpr to avoid an infinite loop if we're initializing an array of unknown bound. llvm-svn: 164851
-rw-r--r--clang/lib/Sema/SemaInit.cpp2
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp6
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index c4314b6f6ce..42fc84d4328 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -1316,6 +1316,8 @@ void InitListChecker::CheckStructUnionTypes(const InitializedEntity &Entity,
// If the record is invalid, some of it's members are invalid. To avoid
// confusion, we forgo checking the intializer for the entire record.
if (structDecl->isInvalidDecl()) {
+ // Assume it was supposed to consume a single initializer.
+ ++Index;
hadError = true;
return;
}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp
index 10415711533..2342807692e 100644
--- a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp
@@ -16,3 +16,9 @@ void tf() {
// Allowed by GNU extension
int a4[] = {}; // expected-error {{zero size arrays}}
+
+struct Incomplete; // expected-note {{forward declaration of 'Incomplete'}}
+struct A {
+ Incomplete i; // expected-error {{field has incomplete type 'Incomplete'}}
+};
+A a[] = { 0 }; // PR13971: don't hang.
OpenPOWER on IntegriCloud