diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 9b91cd97c..1974caa4a 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -149,6 +149,14 @@ bool isSameExpression(bool cpp, bool macro, const Token *tok1, const Token *tok2 } if (macro && (tok1->isExpandedMacro() || tok2->isExpandedMacro())) return false; + if (tok1->isComplex() != tok2->isComplex()) + return false; + if (tok1->isLong() != tok2->isLong()) + return false; + if (tok1->isUnsigned() != tok2->isUnsigned()) + return false; + if (tok1->isSigned() != tok2->isSigned()) + return false; if (tok1->isName() && tok1->next()->str() == "(" && tok1->str() != "sizeof") { if (!tok1->function() && !Token::Match(tok1->previous(), ".|::") && pure && !library.isFunctionConst(tok1->str(), true) && !tok1->isAttributeConst() && !tok1->isAttributePure()) return false; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 32292ab7f..225eb37d7 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -564,6 +564,12 @@ private: " else if (x == 40) {}\n" "}"); ASSERT_EQUALS("[test.cpp:3]: (style) Expression is always false because 'else if' condition matches previous condition at line 2.\n", errout.str()); + + check("void f(int x) {\n" + " if (x == sizeof(double)) {}\n" + " else { if (x == sizeof(long double)) {} }" + "}"); + ASSERT_EQUALS("", errout.str()); } void checkBadBitmaskCheck() {