]> granicus.if.org Git - clang/commitdiff
Fix a crash for nested initializer list initialization. Still does the wrong thing...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Sun, 19 Feb 2012 12:27:43 +0000 (12:27 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Sun, 19 Feb 2012 12:27:43 +0000 (12:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150922 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInit.cpp

index fb97b00ace452040c7ceb331965e7194c14c62fa..28b99f9e4c3fdb2e9237948210bcd0de39205453 100644 (file)
@@ -3078,16 +3078,25 @@ static void TryListInitialization(Sema &S,
     TryReferenceListInitialization(S, Entity, Kind, InitList, Sequence);
     return;
   }
-  if (DestType->isRecordType() && !DestType->isAggregateType()) {
-    if (S.getLangOptions().CPlusPlus0x) {
-      Expr *Arg = InitList;
-      // A direct-initializer is not list-syntax, i.e. there's no special
-      // treatment of "A a({1, 2});".
-      TryConstructorInitialization(S, Entity, Kind, &Arg, 1, DestType,
-                    Sequence, Kind.getKind() != InitializationKind::IK_Direct);
-    } else
-      Sequence.SetFailed(InitializationSequence::FK_InitListBadDestinationType);
-    return;
+  if (DestType->isRecordType()) {
+    if (S.RequireCompleteType(InitList->getLocStart(), DestType, S.PDiag())) {
+      Sequence.SetFailed(InitializationSequence::FK_Incomplete);
+      return;
+    }
+
+    if (!DestType->isAggregateType()) {
+      if (S.getLangOptions().CPlusPlus0x) {
+        Expr *Arg = InitList;
+        // A direct-initializer is not list-syntax, i.e. there's no special
+        // treatment of "A a({1, 2});".
+        TryConstructorInitialization(S, Entity, Kind, &Arg, 1, DestType, 
+                                     Sequence,
+                               Kind.getKind() != InitializationKind::IK_Direct);
+      } else
+        Sequence.SetFailed(
+            InitializationSequence::FK_InitListBadDestinationType);
+      return;
+    }
   }
 
   InitListChecker CheckInitList(S, Entity, InitList,