diff options
-rw-r--r-- | lib/Sema/SemaInit.cpp | 2 | ||||
-rw-r--r-- | test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index c4314b6f6c..42fc84d432 100644 --- a/lib/Sema/SemaInit.cpp +++ b/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/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp index 1041571153..2342807692 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp +++ b/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. |