Fix #10923 FP constStatement with ptr to ptr to ptr (#3944)

* Fix #10923 FP constStatement with ptr to ptr to ptr

* simpleMatch
This commit is contained in:
chrchr-github 2022-03-26 06:12:26 +01:00 committed by GitHub
parent a143fa37dd
commit 5ed521622f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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 ("))

View File

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