mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
CPP: Add to UnusedStaticVariables tests.
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
| 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:10:11:10:19 | constVar8 | Static variable constVar8 is never read |
|
||||
| test.cpp:12:12:12:22 | staticVar10 | Static variable staticVar10 is never read |
|
||||
|
||||
@@ -7,6 +7,9 @@ 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)
|
||||
const int constVar8 = 8; // BAD (const defaults to static)
|
||||
extern const int constVar9 = 9; // GOOD
|
||||
static int staticVar10 = 10; // GOOD [FALSE POSITIVE] (referenced in a never instantiated template)
|
||||
|
||||
void f()
|
||||
{
|
||||
@@ -16,3 +19,12 @@ void f()
|
||||
(*ptr) = 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
class MyTemplateClass // never instantiated
|
||||
{
|
||||
public:
|
||||
MyTemplateClass(int param = staticVar10)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user