diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 8eec9f04c..3844333e6 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2246,7 +2246,7 @@ T* getTokenArgumentFunctionImpl(T* tok, int& argn) parent = parent->astParent(); // passing variable to subfunction? - if (Token::Match(parent, "[*[(,{]")) + if (Token::Match(parent, "[*[(,{]") || Token::Match(parent, "%oror%|&&")) ; else if (Token::simpleMatch(parent, ":")) { while (Token::Match(parent, "[?:]")) diff --git a/lib/checkstring.cpp b/lib/checkstring.cpp index f4b324fcf..b24b71095 100644 --- a/lib/checkstring.cpp +++ b/lib/checkstring.cpp @@ -255,9 +255,13 @@ void CheckString::strPlusCharError(const Token *tok) static bool isMacroUsage(const Token* tok) { if (const Token* parent = tok->astParent()) { + while (parent && parent->isCast()) + parent = parent->astParent(); + if (!parent) + return false; if (parent->isExpandedMacro()) return true; - if (parent->isUnaryOp("!")) { + if (parent->isUnaryOp("!") || parent->isComparisonOp()) { int argn{}; const Token* ftok = getTokenArgumentFunction(parent, argn); if (ftok && !ftok->function()) diff --git a/test/teststring.cpp b/test/teststring.cpp index e94f96903..0ef106007 100644 --- a/test/teststring.cpp +++ b/test/teststring.cpp @@ -799,6 +799,12 @@ private: " return false;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f(const int* p, const int* q) {\n" + " assert((p != NULL && q != NULL) || !\"abc\");\n" + " ASSERT((void*)(\"def\") == 0);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void deadStrcmp() {