C++: Test for DeclarationHidesVariable FP

This commit is contained in:
Jonas Jensen
2019-07-05 20:34:30 +02:00
parent 50e8034b0b
commit 443a8fbc07
2 changed files with 11 additions and 3 deletions

View File

@@ -1,2 +1,5 @@
| 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:30:5:30:5 | (__begin) | Variable (__begin) hides another variable of the same name (on $@). | hiding.cpp:29:3:29:3 | (__begin) | line 29 |
| hiding.cpp:30:5:30:5 | (__end) | Variable (__end) hides another variable of the same name (on $@). | hiding.cpp:29:3:29:3 | (__end) | line 29 |
| hiding.cpp:30:5:30:5 | (__range) | Variable (__range) hides another variable of the same name (on $@). | hiding.cpp:29:3:29:3 | (__range) | line 29 |

View File

@@ -3,7 +3,7 @@ void f(void) {
if (1) {
int i;
for(int i = 1; i < 10; i++) {
for(int i = 1; i < 10; i++) { // BAD
;
}
}
@@ -15,7 +15,7 @@ namespace foo {
int k;
try {
for (i = 0; i < 3; i++) {
int k;
int k; // BAD
}
}
catch (int e) {
@@ -24,4 +24,9 @@ namespace foo {
}
}
void nestedRangeBasedFor() {
int xs[4], ys[4];
for (auto x : xs)
for (auto y : ys) // GOOD [FALSE POSITIVE]
x = y = 0;
}