File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -3902,7 +3902,7 @@ void CheckOther::checkKnownArgument()
39023902 const SymbolDatabase *symbolDatabase = mTokenizer ->getSymbolDatabase ();
39033903 for (const Scope *functionScope : symbolDatabase->functionScopes ) {
39043904 for (const Token *tok = functionScope->bodyStart ; tok != functionScope->bodyEnd ; tok = tok->next ()) {
3905- if (!tok->hasKnownIntValue ())
3905+ if (!tok->hasKnownIntValue () || tok-> isExpandedMacro () )
39063906 continue ;
39073907 if (Token::Match (tok, " ++|--|%assign%" ))
39083908 continue ;
Original file line number Diff line number Diff line change @@ -12195,6 +12195,12 @@ class TestOther : public TestFixture {
1219512195 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 "
1219612196 " [test.cpp:4]: (style) Argument 'i-1*i' to constructor S is always 0. It does not matter what value 'i' has.\n " ,
1219712197 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 ());
1219812204 }
1219912205
1220012206 void knownArgumentHiddenVariableExpression () {
You can’t perform that action at this time.
0 commit comments