From: Richard Smith Date: Thu, 23 May 2013 23:20:04 +0000 (+0000) Subject: Fix crash-on-invalid if list-initialization works, but we bail out when X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2c2f09ec4842be9933f803b1ec9488b62afc9f5c;p=clang Fix crash-on-invalid if list-initialization works, but we bail out when building the resulting expression because it invokes a deleted constructor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182624 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index f7b53b2be2..fdb8777d41 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -5745,7 +5745,8 @@ InitializationSequence::Perform(Sema &S, ExprResult Res = S.PerformCopyInitialization( Element, Init.get()->getExprLoc(), Init, /*TopLevelOfInitList=*/ true); - assert(!Res.isInvalid() && "Result changed since try phase."); + if (Res.isInvalid()) + return ExprError(); Converted[i] = Res.take(); } InitListExpr *Semantic = new (S.Context) diff --git a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp index 88571d671b..0f7eb77c86 100644 --- a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -208,3 +208,13 @@ namespace init_list_deduction_failure { void h() { g({f}); } // expected-error@-1 {{no matching function for call to 'g'}} } + +namespace deleted_copy { + struct X { + X(int i) {} + X(const X& x) = delete; // expected-note {{here}} + void operator=(const X& x) = delete; + }; + + std::initializer_list x{1}; // expected-error {{invokes deleted constructor}} +}