diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 91021b6c9..547b997d0 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -34,6 +34,9 @@ namespace { static bool astIsFloat(const Token *tok, bool unknown) { + if (tok->str() == ".") + return astIsFloat(tok->astOperand2(), unknown); + if (tok->astOperand1() && tok->str() != "?" && astIsFloat(tok->astOperand1(),unknown)) return true; if (tok->astOperand2() && astIsFloat(tok->astOperand2(), unknown)) diff --git a/test/testother.cpp b/test/testother.cpp index 0f0d2bd7b..5d0f9b23e 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4983,6 +4983,10 @@ private: "float f(struct X x) { return x.f == x.f; }"); ASSERT_EQUALS("", errout.str()); + check("struct X { int i; };\n" + "int f(struct X x) { return x.i == x.i; }"); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Same expression on both sides of '=='.\n", errout.str()); + // #5284 - when type is unknown, assume it's float check("int f() { return x==x; }"); ASSERT_EQUALS("", errout.str());