diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 4482ebad4e7..e1772825701 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -7573,7 +7573,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to else if (tok->previous()->isSigned()) valuetype.sign = ValueType::Sign::SIGNED; else if (valuetype.isIntegral() && valuetype.type != ValueType::UNKNOWN_INT) - valuetype.sign = mDefaultSignedness; + valuetype.sign = (valuetype.type == ValueType::Type::CHAR) ? mDefaultSignedness : ValueType::Sign::SIGNED; setValueType(tok, valuetype); } diff --git a/test/testcondition.cpp b/test/testcondition.cpp index db2f41e6da2..35a7205642c 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -6229,6 +6229,28 @@ class TestCondition : public TestFixture { "}\n"); ASSERT_EQUALS("", errout_str()); } + + void knownConditionFloating() { + check("void foo() {\n" // #13363 + " float f = 1.0f;\n" + " if (f > 1.00f) {}\n" + " if (f > 1) {}\n" + "}\n"); + ASSERT_EQUALS( + "[test.cpp:3]: (style) Condition 'f>1.00f' is always false\n" + "[test.cpp:4]: (style) Condition 'f>1' is always false\n", + errout_str()); + + check("void foo() {\n" // #13363 + " float f = 1.0;\n" + " if (f > 1.00) {}\n" + " if (f > 1) {}\n" + "}\n"); + ASSERT_EQUALS( + "[test.cpp:3]: (style) Condition 'f>1.00' is always false\n" + "[test.cpp:4]: (style) Condition 'f>1' is always false\n", + errout_str()); + } }; REGISTER_TEST(TestCondition)