Add test for structured binding declaration hiding variable

This commit is contained in:
Jeroen Ketema
2022-01-26 15:06:33 +01:00
parent b380ba0d8f
commit 10a94cfa45
2 changed files with 11 additions and 0 deletions

View File

@@ -1,2 +1,4 @@
| 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 |
| 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 |
| 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 |
| 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 |

View File

@@ -30,3 +30,12 @@ void nestedRangeBasedFor() {
for (auto y : ys) // GOOD
x = y = 0;
}
void structuredBinding() {
int xs[1] = {1};
auto [x] = xs;
{
auto [x] = xs; // BAD
auto [y] = xs; // GOOD [FALSE POSITIVE]
}
}