During constant evaluation, handle CXXBindTemporaryExprs for

array-of-class types, not just for class types.

llvm-svn: 373279
This commit is contained in:
Richard Smith 2019-10-01 00:41:16 +00:00
parent 5ca306666c
commit 3b69bcc363
2 changed files with 11 additions and 7 deletions

View File

@ -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);
};
}

View File

@ -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 {