From: Richard Smith Date: Mon, 30 Sep 2019 22:55:27 +0000 (+0000) Subject: Fix crash on value-dependent delete-expressions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bf7457872bd47ea71c745ebb6b1e4d260445cf65;p=clang Fix crash on value-dependent delete-expressions. We used to miscompute the 'value-dependent' bit, and would crash if we tried to evaluate a delete expression that should be value-dependent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373272 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 8e13eb5fdb..61e7a91d9f 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -2278,8 +2278,8 @@ public: CXXDeleteExpr(QualType Ty, bool GlobalDelete, bool ArrayForm, bool ArrayFormAsWritten, bool UsualArrayDeleteWantsSize, FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc) - : Expr(CXXDeleteExprClass, Ty, VK_RValue, OK_Ordinary, false, false, - Arg->isInstantiationDependent(), + : Expr(CXXDeleteExprClass, Ty, VK_RValue, OK_Ordinary, false, + Arg->isValueDependent(), Arg->isInstantiationDependent(), Arg->containsUnexpandedParameterPack()), OperatorDelete(OperatorDelete), Argument(Arg) { CXXDeleteExprBits.GlobalDelete = GlobalDelete; diff --git a/test/SemaCXX/constant-expression-cxx2a.cpp b/test/SemaCXX/constant-expression-cxx2a.cpp index 0cf41d8f44..08fcfdd281 100644 --- a/test/SemaCXX/constant-expression-cxx2a.cpp +++ b/test/SemaCXX/constant-expression-cxx2a.cpp @@ -1056,6 +1056,12 @@ namespace delete_random_things { static_assert((delete &(int&)(int&&)0, true)); // expected-error {{}} expected-note {{delete of pointer '&0' that does not point to a heap-allocated object}} expected-note {{temporary created here}} } +namespace value_dependent_delete { + template void f(T *p) { + int arr[(delete p, 0)]; + } +} + namespace memory_leaks { static_assert(*new bool(true)); // expected-error {{}} expected-note {{allocation performed here was not deallocated}}