r182624 - Fix crash-on-invalid if list-initialization works, but we bail out when
Richard Smith
richard-llvm at metafoo.co.uk
Thu May 23 16:20:04 PDT 2013
Author: rsmith
Date: Thu May 23 18:20:04 2013
New Revision: 182624
URL: http://llvm.org/viewvc/llvm-project?rev=182624&view=rev
Log:
Fix crash-on-invalid if list-initialization works, but we bail out when
building the resulting expression because it invokes a deleted constructor.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=182624&r1=182623&r2=182624&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu May 23 18:20:04 2013
@@ -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)
Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=182624&r1=182623&r2=182624&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Thu May 23 18:20:04 2013
@@ -208,3 +208,13 @@ namespace init_list_deduction_failure {
void h() { g({f}); }
// expected-error at -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}}
+}
More information about the cfe-commits
mailing list