File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedStaticVariables Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 11| test.cpp:7:12:7:21 | staticVar5 | Static variable staticVar5 is never read |
22| test.cpp:8:12:8:21 | staticVar6 | Static variable staticVar6 is never read |
3+ | test.cpp:10:11:10:19 | constVar8 | Static variable constVar8 is never read |
4+ | test.cpp:12:12:12:22 | staticVar10 | Static variable staticVar10 is never read |
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ static int staticVar4 = staticVar3; // GOOD (used)
77static int staticVar5; // BAD (unused)
88static int staticVar6 = 6 ; // BAD (unused)
99static __attribute__ ((__unused__)) int staticVar7; // GOOD (unused but this is expected)
10+ const int constVar8 = 8 ; // BAD (const defaults to static)
11+ extern const int constVar9 = 9 ; // GOOD
12+ static int staticVar10 = 10 ; // GOOD [FALSE POSITIVE] (referenced in a never instantiated template)
1013
1114void f ()
1215{
@@ -16,3 +19,12 @@ void f()
1619 (*ptr) = 0 ;
1720}
1821
22+ template <class T >
23+ class MyTemplateClass // never instantiated
24+ {
25+ public:
26+ MyTemplateClass (int param = staticVar10)
27+ {
28+ // ...
29+ }
30+ };
You can’t perform that action at this time.
0 commit comments