Skip to content

Commit 2b43e52

Browse files
committed
fixed #13363 - apply default signedness to char only [skip ci]
1 parent f441e77 commit 2b43e52

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7573,7 +7573,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
75737573
else if (tok->previous()->isSigned())
75747574
valuetype.sign = ValueType::Sign::SIGNED;
75757575
else if (valuetype.isIntegral() && valuetype.type != ValueType::UNKNOWN_INT)
7576-
valuetype.sign = mDefaultSignedness;
7576+
valuetype.sign = (valuetype.type == ValueType::Type::CHAR) ? mDefaultSignedness : ValueType::Sign::SIGNED;
75777577
setValueType(tok, valuetype);
75787578
}
75797579

test/testcondition.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6229,6 +6229,28 @@ class TestCondition : public TestFixture {
62296229
"}\n");
62306230
ASSERT_EQUALS("", errout_str());
62316231
}
6232+
6233+
void knownConditionFloating() {
6234+
check("void foo() {\n" // #13363
6235+
" float f = 1.0f;\n"
6236+
" if (f > 1.00f) {}\n"
6237+
" if (f > 1) {}\n"
6238+
"}\n");
6239+
ASSERT_EQUALS(
6240+
"[test.cpp:3]: (style) Condition 'f>1.00f' is always false\n"
6241+
"[test.cpp:4]: (style) Condition 'f>1' is always false\n",
6242+
errout_str());
6243+
6244+
check("void foo() {\n" // #13363
6245+
" float f = 1.0;\n"
6246+
" if (f > 1.00) {}\n"
6247+
" if (f > 1) {}\n"
6248+
"}\n");
6249+
ASSERT_EQUALS(
6250+
"[test.cpp:3]: (style) Condition 'f>1.00' is always false\n"
6251+
"[test.cpp:4]: (style) Condition 'f>1' is always false\n",
6252+
errout_str());
6253+
}
62326254
};
62336255

62346256
REGISTER_TEST(TestCondition)

0 commit comments

Comments
 (0)