You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b2d8361
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: test/testother.cpp
+40Lines changed: 40 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -11555,6 +11555,46 @@ class TestOther : public TestFixture {
11555
11555
"[test.cpp:8:10]: note: i is initialized\n"
11556
11556
"[test.cpp:9:7]: note: i is overwritten\n",
11557
11557
errout_str());
11558
+
11559
+
check("struct S { int a, b; };\n" // #15021
11560
+
"int f(S s) {\n"
11561
+
" auto [x, y] = s;\n"
11562
+
" x = 1;\n"
11563
+
" y = 2;\n"
11564
+
" return x + y;\n"
11565
+
"}\n"
11566
+
"struct T { int c; };\n"
11567
+
"int g(T t) {\n"
11568
+
" auto [z] = t;\n"
11569
+
" z = 0;\n"
11570
+
" return z;\n"
11571
+
"}\n");
11572
+
ASSERT_EQUALS("[test.cpp:4:7]: style: Redundant initialization for 'x'. The initialized value is overwritten before it is read. [redundantInitialization]\n"
11573
+
"[test.cpp:3:17]: note: x is initialized\n"
11574
+
"[test.cpp:4:7]: note: x is overwritten\n"
11575
+
"[test.cpp:5:7]: style: Redundant initialization for 'y'. The initialized value is overwritten before it is read. [redundantInitialization]\n"
11576
+
"[test.cpp:3:17]: note: y is initialized\n"
11577
+
"[test.cpp:5:7]: note: y is overwritten\n"
11578
+
"[test.cpp:11:7]: style: Redundant initialization for 'z'. The initialized value is overwritten before it is read. [redundantInitialization]\n"
11579
+
"[test.cpp:10:14]: note: z is initialized\n"
11580
+
"[test.cpp:11:7]: note: z is overwritten\n",
11581
+
errout_str());
11582
+
11583
+
check("struct S {\n"
11584
+
" int a, b;\n"
11585
+
"};\n"
11586
+
"void f(S& s) {\n"
11587
+
" auto& [x, y] = s;\n"
11588
+
" y = 1;\n"
11589
+
"}\n"
11590
+
"void f(S s) {\n"
11591
+
" auto [x, y] = s;\n"
11592
+
" y = 1;\n"
11593
+
"}\n");
11594
+
ASSERT_EQUALS("[test.cpp:10:7]: style: Redundant initialization for 'y'. The initialized value is overwritten before it is read. [redundantInitialization]\n"
0 commit comments