From 5ed521622f772c791c09b12168895184c45c3d3a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 26 Mar 2022 06:12:26 +0100 Subject: [PATCH] Fix #10923 FP constStatement with ptr to ptr to ptr (#3944) * Fix #10923 FP constStatement with ptr to ptr to ptr * simpleMatch --- lib/checkother.cpp | 2 ++ test/testother.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 48d6b24e0..325ee63c2 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1769,6 +1769,8 @@ static bool isConstStatement(const Token *tok, bool cpp) return false; if (Token::Match(tok, "<<|>>") && !astIsIntegral(tok, false)) return false; + if (tok->astTop() && Token::simpleMatch(tok->astTop()->astOperand1(), "delete")) + return false; if (Token::Match(tok, "!|~|%cop%") && (tok->astOperand1() || tok->astOperand2())) return true; if (Token::simpleMatch(tok->previous(), "sizeof (")) diff --git a/test/testother.cpp b/test/testother.cpp index 0d3512054..dd92048eb 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4809,6 +4809,11 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + check("void f(const int*** p) {\n" // #10923 + " delete[] **p;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + check("void *f(char** c) {\n" " bar(**c++);\n" "}");