Fix crash-on-invalid if list-initialization works, but we bail out when

building the resulting expression because it invokes a deleted constructor.

llvm-svn: 182624
This commit is contained in:
Richard Smith 2013-05-23 23:20:04 +00:00
parent 4814317516
commit cd09065ec3
2 changed files with 12 additions and 1 deletions

View 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)

View 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}}
}