diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-07 18:45:03 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-07 18:45:03 +0000 |
commit | 9ff62af3aa22f383e978833409f232f5614fb26b (patch) | |
tree | ed549e69c4972c5063d665730a65fa037862b8c0 /clang | |
parent | faed9c671edbf07389e304c16c2f112909bd43f7 (diff) | |
download | bcm5719-llvm-9ff62af3aa22f383e978833409f232f5614fb26b.tar.gz bcm5719-llvm-9ff62af3aa22f383e978833409f232f5614fb26b.zip |
PR17615: A delegating constructor initializer is a full-expression. Don't
forget to clean up temporaries at the end of it.
llvm-svn: 194213
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx1y.cpp | 11 |
2 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 2412facf05c..cd984a251c9 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -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; } diff --git a/clang/test/SemaCXX/constant-expression-cxx1y.cpp b/clang/test/SemaCXX/constant-expression-cxx1y.cpp index 7a2fa44c217..136f7b198a8 100644 --- a/clang/test/SemaCXX/constant-expression-cxx1y.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx1y.cpp @@ -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}} +} |