diff --git a/lib/checkstring.cpp b/lib/checkstring.cpp index dc60d40f22d..7062a5805f7 100644 --- a/lib/checkstring.cpp +++ b/lib/checkstring.cpp @@ -254,8 +254,11 @@ void CheckString::strPlusCharError(const Token *tok) static bool isMacroUsage(const Token* tok) { if (const Token* parent = tok->astParent()) { - while (parent && (parent->isCast() || parent->str() == "&&")) + while (parent && (parent->isCast() || parent->str() == "&&")) { + if (parent->isExpandedMacro()) + return true; parent = parent->astParent(); + } if (!parent) return false; if (parent->isExpandedMacro()) diff --git a/test/teststring.cpp b/test/teststring.cpp index 59202c4a745..9a00c1944cb 100644 --- a/test/teststring.cpp +++ b/test/teststring.cpp @@ -808,6 +808,12 @@ class TestString : public TestFixture { " MACRO(false && \"abc\");\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("#define strequ(s1,s2) ((void *)s1 && (void *)s2 && strcmp(s1, s2) == 0)\n" // #13093 + "void f(const char* p) {\n" + " if (strequ(p, \"ALL\")) {}\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void deadStrcmp() {