Skip to content

Commit a26b16d

Browse files
Fix #12712 FN duplicateCondition with function in namespace (#6386)
1 parent 50be22d commit a26b16d

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

lib/astutils.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,8 +1684,6 @@ bool isSameExpression(bool macro, const Token *tok1, const Token *tok2, const Se
16841684
return false;
16851685
} else {
16861686
const Token * ftok = tok1;
1687-
if (Token::simpleMatch(tok1->previous(), "::"))
1688-
ftok = tok1->previous();
16891687
if (!settings.library.isFunctionConst(ftok) && !ftok->isAttributeConst() && !ftok->isAttributePure())
16901688
return false;
16911689
}

test/testcondition.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5558,6 +5558,12 @@ class TestCondition : public TestFixture {
55585558
"}\n");
55595559
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:6]: (style) The if condition is the same as the previous if condition\n", errout_str());
55605560

5561+
check("void f(double d) {\n" // #12712
5562+
" if (std::isfinite(d)) {}\n"
5563+
" if (std::isfinite(d)) {}\n"
5564+
"}\n");
5565+
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) The if condition is the same as the previous if condition\n", errout_str());
5566+
55615567
// do not crash
55625568
check("void assign(const MMA& other) {\n"
55635569
" if (mPA.cols != other.mPA.cols || mPA.rows != other.mPA.rows)\n"

0 commit comments

Comments
 (0)