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 f7b53b2..fdb8777 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -5745,7 +5745,8 @@
         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 88571d6..0f7eb77 100644
--- a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -208,3 +208,13 @@
   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}}
+}