Skip to content

Commit 10a94cf

Browse files
committed
Add test for structured binding declaration hiding variable
1 parent b380ba0 commit 10a94cf

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
| hiding.cpp:6:17:6:17 | i | Variable i hides another variable of the same name (on $@). | hiding.cpp:4:13:4:13 | i | line 4 |
22
| hiding.cpp:18:15:18:15 | k | Variable k hides another variable of the same name (on $@). | hiding.cpp:15:11:15:11 | k | line 15 |
3+
| hiding.cpp:38:10:38:10 | (unnamed local variable) | Variable (unnamed local variable) hides another variable of the same name (on $@). | hiding.cpp:36:8:36:8 | (unnamed local variable) | line 36 |
4+
| hiding.cpp:39:10:39:10 | (unnamed local variable) | Variable (unnamed local variable) hides another variable of the same name (on $@). | hiding.cpp:36:8:36:8 | (unnamed local variable) | line 36 |

cpp/ql/test/query-tests/Best Practices/Hiding/DeclarationHidesVariable/hiding.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,12 @@ void nestedRangeBasedFor() {
3030
for (auto y : ys) // GOOD
3131
x = y = 0;
3232
}
33+
34+
void structuredBinding() {
35+
int xs[1] = {1};
36+
auto [x] = xs;
37+
{
38+
auto [x] = xs; // BAD
39+
auto [y] = xs; // GOOD [FALSE POSITIVE]
40+
}
41+
}

0 commit comments

Comments
 (0)