Skip to content

Commit 976db09

Browse files
committed
Added new testcase for known value outside integer range
1 parent cd494b2 commit 976db09

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/testtype.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,13 @@ class TestType : public TestFixture {
478478
check(code4, dinit(CheckOptions, $.settings = &settings));
479479
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());
480480

481+
const char code5[] = "long f() {\n"
482+
" unsigned int n = 1U << 20;\n"
483+
" return n << 20;\n"
484+
"}\n";
485+
check(code5, dinit(CheckOptions, $.settings = &settings));
486+
ASSERT_EQUALS("[test.cpp:3: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());
487+
481488
// typedef
482489
check("size_t f(int x, int y) {\n"
483490
" return x * y;\n"

0 commit comments

Comments
 (0)