diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index eb4c74d9f..b3b0885a5 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -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()) diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index 336f2a38a..99d0d6838 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -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() {