mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
Structured bindings are now handled better, so the false negative related to structured bindings is now a true positive.
42 lines
606 B
C++
42 lines
606 B
C++
// semmle-extractor-options: -std=c++17
|
|
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;
|
|
}
|
|
|
|
void structuredBinding() {
|
|
int xs[1] = {1};
|
|
auto [x] = xs;
|
|
{
|
|
auto [x] = xs; // BAD
|
|
auto [y] = xs; // GOOD
|
|
}
|
|
}
|