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
12 changes: 8 additions & 4 deletions lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1615,10 +1615,14 @@ bool isSameExpression(bool macro, const Token *tok1, const Token *tok2, const Se
return false;

const Token *followTok1 = tok1, *followTok2 = tok2;
while (Token::simpleMatch(followTok1, "::") && followTok1->astOperand2())
followTok1 = followTok1->astOperand2();
while (Token::simpleMatch(followTok2, "::") && followTok2->astOperand2())
followTok2 = followTok2->astOperand2();
while (Token::simpleMatch(followTok1, "::"))
followTok1 = followTok1->astOperand2() ? followTok1->astOperand2() : followTok1->astOperand1();
if (!followTok1)
followTok1 = tok1; // TODO: remove after #14235 has been fixed
while (Token::simpleMatch(followTok2, "::"))
followTok2 = followTok2->astOperand2() ? followTok2->astOperand2() : followTok2->astOperand1();
if (!followTok2)
followTok2 = tok2;
if (isSameConstantValue(macro, followTok1, followTok2))
return true;

Expand Down
4 changes: 4 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6401,6 +6401,10 @@ class TestOther : public TestFixture {
" s.i = o;\n"
"}\n");
ASSERT_EQUALS("", errout_str());

check("int N;\n" // #14234
"void f() { ::N = N; }\n");
ASSERT_EQUALS("[test.cpp:2:16]: (style) Redundant assignment of '::N' to itself. [selfAssignment]\n", errout_str());
}

void trac1132() {
Expand Down
Loading