diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 155464d5aab..cccd978b400 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3897,7 +3897,7 @@ void CheckOther::checkKnownArgument() const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase(); for (const Scope *functionScope : symbolDatabase->functionScopes) { for (const Token *tok = functionScope->bodyStart; tok != functionScope->bodyEnd; tok = tok->next()) { - if (!tok->hasKnownIntValue()) + if (!tok->hasKnownIntValue() || tok->isExpandedMacro()) continue; if (Token::Match(tok, "++|--|%assign%")) continue; diff --git a/test/testother.cpp b/test/testother.cpp index 4dfb00ac03b..2f5929865a9 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -12164,6 +12164,12 @@ class TestOther : public TestFixture { ASSERT_EQUALS("[test.cpp:3]: (style) Argument 'i-1*i' to init list { is always 0. It does not matter what value 'i' has.\n" "[test.cpp:4]: (style) Argument 'i-1*i' to constructor S is always 0. It does not matter what value 'i' has.\n", errout_str()); + + checkP("#define MACRO(X) std::abs(X ? 0 : a)\n" + "int f(int a) {\n" + " return MACRO(true);\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void knownArgumentHiddenVariableExpression() {