CPP: Add to UnusedStaticVariables tests.

This commit is contained in:
Geoffrey White
2019-03-18 16:38:34 +00:00
parent 5441352d41
commit 73b7b980c8
2 changed files with 14 additions and 0 deletions

View File

@@ -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)
{
// ...
}
};