Skip to content

Commit

Permalink
Remove const requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 24, 2023
1 parent b548bea commit a5773eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/checktype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ void CheckType::checkLongCast()
rhstype->originalTypeName.empty() &&
(lhstype->type == ValueType::Type::LONG || lhstype->type == ValueType::Type::LONGLONG) &&
lhstype->pointer == 0U &&
lhstype->constness == 1U &&
lhstype->originalTypeName.empty() &&
isSmallerTypeSize(rhstype, lhstype, mTokenizer))
longCastAssignError(tok);
Expand Down
6 changes: 6 additions & 0 deletions test/testtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ class TestType : public TestFixture {
check(code, settingsWin);
ASSERT_EQUALS("", errout.str());

check("long f(int x, int y) {\n"
" long ret = x * y;\n"
" return ret;\n"
"}\n", settings);
ASSERT_EQUALS("[test.cpp:2]: (style) int result is assigned to long variable. If the variable is long to avoid loss of information, then you have loss of information.\n", errout.str());

check("long f() {\n"
" const long long ret = 256 * (1 << 10);\n"
" return ret;\n"
Expand Down

0 comments on commit a5773eb

Please sign in to comment.