]> granicus.if.org Git - clang/commitdiff
Fix crash-on-invalid if list-initialization works, but we bail out when
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 23 May 2013 23:20:04 +0000 (23:20 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 23 May 2013 23:20:04 +0000 (23:20 +0000)
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

lib/Sema/SemaInit.cpp
test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp

index f7b53b2be21092a5d31066793f6805d50c2b3dc7..fdb8777d41e6a58ea760da3e5827353f586e4512 100644 (file)
@@ -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)
index 88571d671b0737a8afacf17951a82398aa1c48fa..0f7eb77c864570c1f11bd4cd6037248573cba0ac 100644 (file)
@@ -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> x{1}; // expected-error {{invokes deleted constructor}}
+}