Skip to content

Commit 9ff62af

Browse files
committed
PR17615: A delegating constructor initializer is a full-expression. Don't
forget to clean up temporaries at the end of it. llvm-svn: 194213
1 parent faed9c6 commit 9ff62af

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3623,8 +3623,11 @@ static bool HandleConstructorCall(SourceLocation CallLoc, const LValue &This,
36233623
// If it's a delegating constructor, just delegate.
36243624
if (Definition->isDelegatingConstructor()) {
36253625
CXXConstructorDecl::init_const_iterator I = Definition->init_begin();
3626-
if (!EvaluateInPlace(Result, Info, This, (*I)->getInit()))
3627-
return false;
3626+
{
3627+
FullExpressionRAII InitScope(Info);
3628+
if (!EvaluateInPlace(Result, Info, This, (*I)->getInit()))
3629+
return false;
3630+
}
36283631
return EvaluateStmt(Result, Info, Definition->getBody()) != ESR_Failed;
36293632
}
36303633

clang/test/SemaCXX/constant-expression-cxx1y.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,14 @@ namespace Bitfields {
887887
}
888888
static_assert(test(), "");
889889
}
890+
891+
namespace PR17615 {
892+
struct A {
893+
int &&r;
894+
constexpr A(int &&r) : r(static_cast<int &&>(r)) {}
895+
constexpr A() : A(0) {
896+
(void)+r; // expected-note {{outside its lifetime}}
897+
}
898+
};
899+
constexpr int k = A().r; // expected-error {{constant expression}} expected-note {{in call to}}
900+
}

0 commit comments

Comments
 (0)