diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-01 00:41:16 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-01 00:41:16 +0000 |
| commit | 3b69bcc363d7e5b518dc673203e6ff88cd2498cb (patch) | |
| tree | 906323ab2750bf61828955475038c8938f8eea73 | |
| parent | 5ca306666c485b56866c4ed95472e55ee59ab35d (diff) | |
| download | bcm5719-llvm-3b69bcc363d7e5b518dc673203e6ff88cd2498cb.tar.gz bcm5719-llvm-3b69bcc363d7e5b518dc673203e6ff88cd2498cb.zip | |
During constant evaluation, handle CXXBindTemporaryExprs for
array-of-class types, not just for class types.
llvm-svn: 373279
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 13 | ||||
| -rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx2a.cpp | 5 |
2 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5659a0eced6..cf28ecbe5ff 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -6493,6 +6493,12 @@ public: return StmtVisitorTy::Visit(E->getSubExpr()) && Scope.destroy(); } + // Temporaries are registered when created, so we don't care about + // CXXBindTemporaryExpr. + bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E) { + return StmtVisitorTy::Visit(E->getSubExpr()); + } + bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E) { CCEDiag(E, diag::note_constexpr_invalid_cast) << 0; return static_cast<Derived*>(this)->VisitCastExpr(E); @@ -8448,13 +8454,6 @@ namespace { bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E); bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T); bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E); - - // Temporaries are registered when created, so we don't care about - // CXXBindTemporaryExpr. - bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E) { - return Visit(E->getSubExpr()); - } - bool VisitBinCmp(const BinaryOperator *E); }; } diff --git a/clang/test/SemaCXX/constant-expression-cxx2a.cpp b/clang/test/SemaCXX/constant-expression-cxx2a.cpp index 2f23975e2e9..ef3ce5c0ccb 100644 --- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx2a.cpp @@ -802,6 +802,11 @@ namespace dtor { return true; } static_assert(run_dtors_on_array_filler()); + + // Ensure that we can handle temporary cleanups for array temporaries. + struct ArrElem { constexpr ~ArrElem() {} }; + using Arr = ArrElem[3]; + static_assert((Arr{}, true)); } namespace dynamic_alloc { |

