Skip to content

Commit 7c764f7

Browse files
Fix #13313 FP knownArgument with macro (#7013)
1 parent da410bb commit 7c764f7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: lib/checkother.cpp

+1-1
Original file line numberDiff line numberDiff 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;

Diff for: test/testother.cpp

+6
Original file line numberDiff line numberDiff 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() {

0 commit comments

Comments
 (0)