mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
CPP: Add a test of UnusedStaticVariable.ql.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
| test.cpp:7:12:7:21 | staticVar5 | Static variable staticVar5 is never read |
|
||||
| test.cpp:8:12:8:21 | staticVar6 | Static variable staticVar6 is never read |
|
||||
| test.cpp:9:40:9:49 | staticVar7 | Static variable staticVar7 is never read |
|
||||
@@ -0,0 +1 @@
|
||||
Best Practices/Unused Entities/UnusedStaticVariables.ql
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
int globalVar; // GOOD (not static)
|
||||
static int staticVar1; // GOOD (used)
|
||||
static int staticVar2; // GOOD (used)
|
||||
static int staticVar3 = 3; // GOOD (used)
|
||||
static int staticVar4 = staticVar3; // GOOD (used)
|
||||
static int staticVar5; // BAD (unused)
|
||||
static int staticVar6 = 6; // BAD (unused)
|
||||
static __attribute__((__unused__)) int staticVar7; // GOOD (unused but this is expected) [FALSE POSITIVE]
|
||||
|
||||
void f()
|
||||
{
|
||||
int *ptr = &staticVar4;
|
||||
|
||||
staticVar1 = staticVar2;
|
||||
(*ptr) = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user