summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-12-19 22:12:41 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-12-19 22:12:41 +0000
commit5894a9138c188766e109f1d7de48c3d1fee0cec6 (patch)
treed2511f3822a5e5325035ea72a99636ac4efb1b43
parentd0b111c3ddfd53869e00f92e782a9373a176cf0e (diff)
downloadbcm5719-llvm-5894a9138c188766e109f1d7de48c3d1fee0cec6.tar.gz
bcm5719-llvm-5894a9138c188766e109f1d7de48c3d1fee0cec6.zip
Evaluation support for ExprWithCleanups. We won't evaluate any expression which
actually requires non-trivial cleanups, so no cleanups need to be performed. llvm-svn: 146916
-rw-r--r--clang/lib/AST/ExprConstant.cpp4
-rw-r--r--clang/test/SemaCXX/constant-expression-cxx11.cpp6
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 630136ea7f8..3c2ffbd0f7b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1799,6 +1799,10 @@ public:
{ return StmtVisitorTy::Visit(E->getReplacement()); }
RetTy VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E)
{ return StmtVisitorTy::Visit(E->getExpr()); }
+ // We cannot create any objects for which cleanups are required, so there is
+ // nothing to do here; all cleanups must come from unevaluated subexpressions.
+ RetTy VisitExprWithCleanups(const ExprWithCleanups *E)
+ { return StmtVisitorTy::Visit(E->getSubExpr()); }
RetTy VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E) {
CCEDiag(E, diag::note_constexpr_invalid_cast) << 0;
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index e4ada1ed832..5798eb59485 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -923,3 +923,9 @@ namespace PR11595 {
}
constexpr int n = f(1); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'f(1)'}}
}
+
+namespace ExprWithCleanups {
+ struct A { A(); ~A(); int get(); };
+ constexpr int get(bool FromA) { return FromA ? A().get() : 1; }
+ constexpr int n = get(false);
+}
OpenPOWER on IntegriCloud