From: Richard Smith Date: Mon, 30 Sep 2019 22:55:27 +0000 (+0000) Subject: Fix crash on value-dependent delete-expressions. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63e8a0f55f53667b1d587ac2d6da4e998009c3f5;p=platform%2Fupstream%2Fllvm.git 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. llvm-svn: 373272 --- diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 8e13eb5..61e7a91 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/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/clang/test/SemaCXX/constant-expression-cxx2a.cpp b/clang/test/SemaCXX/constant-expression-cxx2a.cpp index 0cf41d8..08fcfdd 100644 --- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp +++ b/clang/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}}