]> granicus.if.org Git - clang/commitdiff
Fix crash on value-dependent delete-expressions.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 30 Sep 2019 22:55:27 +0000 (22:55 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 30 Sep 2019 22:55:27 +0000 (22:55 +0000)
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

include/clang/AST/ExprCXX.h
test/SemaCXX/constant-expression-cxx2a.cpp

index 8e13eb5fdbaa1a5ad135cbdd454be0c391b67107..61e7a91d9ff7798e0ee5dbfda75eaafdc7bdc6a7 100644 (file)
@@ -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;
index 0cf41d8f44d0349604f8ab2a881d65b3dc169ec1..08fcfdd281362d22512405f819daf0ff075c8bcc 100644 (file)
@@ -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<typename T> 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}}