]> granicus.if.org Git - clang/commitdiff
PR17615: A delegating constructor initializer is a full-expression. Don't
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 7 Nov 2013 18:45:03 +0000 (18:45 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 7 Nov 2013 18:45:03 +0000 (18:45 +0000)
forget to clean up temporaries at the end of it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194213 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/SemaCXX/constant-expression-cxx1y.cpp

index 2412facf05c6dad627164dfb5d172e3906839654..cd984a251c975eb73b4ab74b3b5193e16d98ed3f 100644 (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;
   }
 
index 7a2fa44c21716410089cd89593381ec85f8e4135..136f7b198a8646f37db4661734224442039d8110 100644 (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}}
+}