diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-02-19 12:27:43 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-02-19 12:27:43 +0000 |
commit | d2231c9424d6cbbcecb6f89cc2de5b987327aeaa (patch) | |
tree | 19b9b2c8db0385fbe7e04db5be863ed4dbb6c31e /lib/Sema/SemaInit.cpp | |
parent | e8e92b9dccc362be33a7f9bb84a114b18db65b10 (diff) |
Fix a crash for nested initializer list initialization. Still does the wrong thing in CodeGen, in that it never destructs anything.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150922 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index fb97b00ace..28b99f9e4c 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -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, |