Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d85f4b5

Browse files
committed
CPP: Fix false positive.
1 parent e7f19e9 commit d85f4b5

3 files changed

Lines changed: 2 additions & 2 deletions

File tree

cpp/ql/src/Best Practices/Unused Entities/UnusedStaticVariables.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ where v.isStatic()
2525
and not v instanceof MemberVariable
2626
and not declarationHasSideEffects(v)
2727
and not v.getAnAttribute().hasName("used")
28+
and not v.getAnAttribute().hasName("unused")
2829
select v, "Static variable " + v.getName() + " is never read"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
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:9:40:9:49 | staticVar7 | Static variable staticVar7 is never read |

cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedStaticVariables/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ static int staticVar3 = 3; // GOOD (used)
66
static int staticVar4 = staticVar3; // GOOD (used)
77
static int staticVar5; // BAD (unused)
88
static int staticVar6 = 6; // BAD (unused)
9-
static __attribute__((__unused__)) int staticVar7; // GOOD (unused but this is expected) [FALSE POSITIVE]
9+
static __attribute__((__unused__)) int staticVar7; // GOOD (unused but this is expected)
1010

1111
void f()
1212
{

0 commit comments

Comments
 (0)