Fix #10875 FP constStatement with delete (#3926)

This commit is contained in:
chrchr-github 2022-03-22 18:39:02 +01:00 committed by GitHub
parent cb6f234a92
commit 40c2687ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -529,7 +529,7 @@ static bool iscast(const Token *tok, bool cpp)
return false;
if (tok->previous() && tok->previous()->isName() && tok->previous()->str() != "return" &&
(!cpp || tok->previous()->str() != "throw"))
(!cpp || !Token::Match(tok->previous(), "delete|throw")))
return false;
if (Token::simpleMatch(tok->previous(), ">") && tok->previous()->link())

View File

@ -497,6 +497,12 @@ private:
"[test.cpp:12]: (warning) Redundant code: Found unused member access.\n"
"[test.cpp:15]: (warning) Redundant code: Found unused member access.\n",
errout.str());
check("struct S { void* p; };\n"
"void f(S s) {\n"
" delete (int*)s.p;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void vardecl() {