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

@@ -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 |

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