]> granicus.if.org Git - clang/commitdiff
When processing an InitListExpr and skipping the initialization of an invalid
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 28 Sep 2012 21:23:50 +0000 (21:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 28 Sep 2012 21:23:50 +0000 (21:23 +0000)
record, skip at least one element from the InitListExpr to avoid an infinite
loop if we're initializing an array of unknown bound.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164851 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInit.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp

index c4314b6f6ce7e593d5e47ae80380e84975aa2c3a..42fc84d43284da6287510fe28138b3254f0231fe 100644 (file)
@@ -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;
   }
index 1041571153354e6ef207e928e15a31003ee72355..2342807692e6011941aedb844246865e97a82ade 100644 (file)
@@ -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.