PR17615: A delegating constructor initializer is a full-expression. Don't

forget to clean up temporaries at the end of it.

llvm-svn: 194213
This commit is contained in:
Richard Smith 2013-11-07 18:45:03 +00:00
parent faed9c671e
commit 9ff62af3aa
2 changed files with 16 additions and 2 deletions

View File

@ -3623,8 +3623,11 @@ static bool HandleConstructorCall(SourceLocation CallLoc, const LValue &This,
// If it's a delegating constructor, just delegate.
if (Definition->isDelegatingConstructor()) {
CXXConstructorDecl::init_const_iterator I = Definition->init_begin();
if (!EvaluateInPlace(Result, Info, This, (*I)->getInit()))
return false;
{
FullExpressionRAII InitScope(Info);
if (!EvaluateInPlace(Result, Info, This, (*I)->getInit()))
return false;
}
return EvaluateStmt(Result, Info, Definition->getBody()) != ESR_Failed;
}

View File

@ -887,3 +887,14 @@ namespace Bitfields {
}
static_assert(test(), "");
}
namespace PR17615 {
struct A {
int &&r;
constexpr A(int &&r) : r(static_cast<int &&>(r)) {}
constexpr A() : A(0) {
(void)+r; // expected-note {{outside its lifetime}}
}
};
constexpr int k = A().r; // expected-error {{constant expression}} expected-note {{in call to}}
}