Files
codeql/cpp/ql/test/query-tests/Best Practices/Hiding/DeclarationHidesVariable/hiding.cpp
Jonas Jensen 8d3cb78a9d C++: Fix DeclarationHidesVariable FP
We don't want alerts about the compiler-generated variables that appear
in the desugaring of range-based `for`.
2019-07-05 20:39:43 +02:00

33 lines
440 B
C++

void f(void) {
if (1) {
int i;
for(int i = 1; i < 10; i++) { // BAD
;
}
}
}
namespace foo {
namespace bar {
void f2(int i) {
int k;
try {
for (i = 0; i < 3; i++) {
int k; // BAD
}
}
catch (int e) {
}
}
}
}
void nestedRangeBasedFor() {
int xs[4], ys[4];
for (auto x : xs)
for (auto y : ys) // GOOD
x = y = 0;
}