diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 92c9b2f29..1d4b2d6a9 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1050,6 +1050,9 @@ bool isConstVarExpression(const Token *tok) std::vector args = getArguments(tok); return std::all_of(args.begin(), args.end(), &isConstVarExpression); } + if (Token::simpleMatch(tok->previous(), "> (") && tok->astOperand2() && tok->astOperand1()->str().find("_cast") != std::string::npos) { + return isConstVarExpression(tok->astOperand2()); + } if (Token::Match(tok, "( %type%")) return isConstVarExpression(tok->astOperand1()); if (Token::Match(tok, "%cop%")) { diff --git a/test/testother.cpp b/test/testother.cpp index 92cb5340c..22d0542ed 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -7599,6 +7599,12 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + check("void g(Foo *);\n" + "void f() {\n" + " g(reinterpret_cast(0));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + check("void g(int);\n" "void f(int x) {\n" " x = 0;\n"