Skip to content

Commit

Permalink
fixed #13363 - apply default signedness to char only [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Jan 1, 2025
1 parent f441e77 commit 2b43e52
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
22 changes: 22 additions & 0 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 2b43e52

Please sign in to comment.