diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 348f9ec641c..35a375d414d 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1684,8 +1684,6 @@ bool isSameExpression(bool macro, const Token *tok1, const Token *tok2, const Se return false; } else { const Token * ftok = tok1; - if (Token::simpleMatch(tok1->previous(), "::")) - ftok = tok1->previous(); if (!settings.library.isFunctionConst(ftok) && !ftok->isAttributeConst() && !ftok->isAttributePure()) return false; } diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 9222c4f27f0..db044308c71 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -5558,6 +5558,12 @@ class TestCondition : public TestFixture { "}\n"); ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:6]: (style) The if condition is the same as the previous if condition\n", errout_str()); + check("void f(double d) {\n" // #12712 + " if (std::isfinite(d)) {}\n" + " if (std::isfinite(d)) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (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"