Skip to content

Commit 968f597

Browse files
committed
Added test case with and without long cast warning
1 parent c331a31 commit 968f597

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/testtype.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,19 @@ class TestType : public TestFixture {
465465
check(code2, dinit(CheckOptions, $.settings = &settingsWin));
466466
ASSERT_EQUALS("[test.cpp:2:3]: (style) int result is returned as long long value. If the return value is long long to avoid loss of information, then you have loss of information. [truncLongCastReturn]\n", errout_str());
467467

468+
const char code3[] = "long f() {\n"
469+
" int n = 1;\n"
470+
" return n << 12;\n"
471+
"}\n";
472+
check(code3, dinit(CheckOptions, $.settings = &settings));
473+
ASSERT_EQUALS("", errout_str());
474+
475+
const char code4[] = "long f(int n) {\n"
476+
" return n << 12;\n"
477+
"}\n";
478+
check(code4, dinit(CheckOptions, $.settings = &settings));
479+
ASSERT_EQUALS("[test.cpp:2:5]: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. [truncLongCastReturn]\n", errout_str());
480+
468481
// typedef
469482
check("size_t f(int x, int y) {\n"
470483
" return x * y;\n"

0 commit comments

Comments
 (0)