File tree 2 files changed +7
-1
lines changed
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -3902,7 +3902,7 @@ void CheckOther::checkKnownArgument()
3902
3902
const SymbolDatabase *symbolDatabase = mTokenizer ->getSymbolDatabase ();
3903
3903
for (const Scope *functionScope : symbolDatabase->functionScopes ) {
3904
3904
for (const Token *tok = functionScope->bodyStart ; tok != functionScope->bodyEnd ; tok = tok->next ()) {
3905
- if (!tok->hasKnownIntValue ())
3905
+ if (!tok->hasKnownIntValue () || tok-> isExpandedMacro () )
3906
3906
continue ;
3907
3907
if (Token::Match (tok, " ++|--|%assign%" ))
3908
3908
continue ;
Original file line number Diff line number Diff line change @@ -12195,6 +12195,12 @@ class TestOther : public TestFixture {
12195
12195
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"
12196
12196
"[test.cpp:4]: (style) Argument 'i-1*i' to constructor S is always 0. It does not matter what value 'i' has.\n",
12197
12197
errout_str());
12198
+
12199
+ checkP("#define MACRO(X) std::abs(X ? 0 : a)\n"
12200
+ "int f(int a) {\n"
12201
+ " return MACRO(true);\n"
12202
+ "}\n");
12203
+ ASSERT_EQUALS("", errout_str());
12198
12204
}
12199
12205
12200
12206
void knownArgumentHiddenVariableExpression() {
You can’t perform that action at this time.
0 commit comments