Skip to content

Commit 2c06401

Browse files
Update testother.cpp
1 parent 757763d commit 2c06401

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test/testother.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11462,6 +11462,23 @@ class TestOther : public TestFixture {
1146211462
" return i;\n"
1146311463
"}\n");
1146411464
ASSERT_EQUALS("", errout_str());
11465+
11466+
check("int f(char c) {\n" // #15037
11467+
" int i = (int)c;\n"
11468+
" i = 3;\n"
11469+
" return i;\n"
11470+
"}\n"
11471+
"int g(char c) {\n"
11472+
" int i = static_cast<int>(c);\n"
11473+
" i = 3;\n"
11474+
" return i;\n"
11475+
"}\n");
11476+
ASSERT_EQUALS("[test.cpp:3:7]: style: Redundant initialization for 'i'. The initialized value is overwritten before it is read. [redundantInitialization]\n"
11477+
"[test.cpp:2:11]: note: i is initialized\n"
11478+
"[test.cpp:3:7]: note: i is overwritten\n"
11479+
"[test.cpp:8:8]: style: Redundant initialization for 'i'. The initialized value is overwritten before it is read. [redundantInitialization]\n"
11480+
"[test.cpp:7:12]: note: i is initialized\n"
11481+
"[test.cpp:8:8]: note: i is overwritten\n", errout_str());
1146511482
}
1146611483

1146711484
// cppcheck-suppress unusedPrivateFunction

0 commit comments

Comments
 (0)