Skip to content

Commit bb44bf4

Browse files
Update testother.cpp
1 parent cdd6b4d commit bb44bf4

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

test/testother.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11462,6 +11462,30 @@ class TestOther : public TestFixture {
1146211462
" return i;\n"
1146311463
"}\n");
1146411464
ASSERT_EQUALS("", errout_str());
11465+
11466+
check("struct S { int a, b; };\n" // #15021
11467+
"int f(S s) {\n"
11468+
" auto [x, y] = s;\n"
11469+
" x = 1;\n"
11470+
" y = 2;\n"
11471+
" return x + y;\n"
11472+
"}\n"
11473+
"struct T { int c; };\n"
11474+
"int g(T t) {\n"
11475+
" auto [z] = t;\n"
11476+
" z = 0;\n"
11477+
" return z;\n"
11478+
"}\n");
11479+
ASSERT_EQUALS("[test.cpp:4:7]: style: Variable 'x' is reassigned a value before the old one has been used. [redundantAssignment]\n"
11480+
"[test.cpp:3:17]: note: x is assigned\n"
11481+
"[test.cpp:4:7]: note: x is overwritten\n"
11482+
"[test.cpp:5:7]: style: Variable 'y' is reassigned a value before the old one has been used. [redundantAssignment]\n"
11483+
"[test.cpp:3:17]: note: y is assigned\n"
11484+
"[test.cpp:5:7]: note: y is overwritten\n"
11485+
"[test.cpp:11:7]: style: Variable 'z' is reassigned a value before the old one has been used. [redundantAssignment]\n"
11486+
"[test.cpp:10:14]: note: z is assigned\n"
11487+
"[test.cpp:11:7]: note: z is overwritten\n",
11488+
errout_str());
1146511489
}
1146611490

1146711491
// cppcheck-suppress unusedPrivateFunction

0 commit comments

Comments
 (0)