Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,7 @@ static bool isExpressionChangedAt(const F& getExprTok,
if (depth < 0)
return true;
if (tok->exprId() != exprid) {
if (globalvar && Token::Match(tok, "%name% ("))
if (globalvar && !tok->isKeyword() && Token::Match(tok, "%name% ("))
// TODO: Is global variable really changed by function call?
return true;
const bool pointer = astIsPointer(tok);
Expand Down
11 changes: 11 additions & 0 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4802,6 +4802,17 @@ class TestCondition : public TestFixture {
"}\n");
ASSERT_EQUALS("", errout.str());

check("struct S { int i; };\n"
"int f(const S& s) {\n"
" int a = 0, b = 0;\n"
" if (s.i == 0)\n"
" a = 1;\n"
" if (s.i == 0)\n"
" b = 1;\n"
" return a + b;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:6]: (style) The if condition is the same as the previous if condition\n", errout.str());

// do not crash
check("void assign(const MMA& other) {\n"
" if (mPA.cols != other.mPA.cols || mPA.rows != other.mPA.rows)\n"
Expand Down