mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
QL: Add tests for FieldOnlyUsedInCharPred.ql
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
| FieldOnlyUsedInCharPred.qll:2:3:2:12 | FieldDecl | Field is only used in CharPred. |
|
||||
| FieldOnlyUsedInCharPred.qll:22:3:22:11 | FieldDecl | Field is only used in CharPred. |
|
||||
@@ -0,0 +1,29 @@
|
||||
class C1 extends int {
|
||||
int field; // BAD
|
||||
|
||||
C1() {
|
||||
this = field and
|
||||
this = 0
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends C1 {
|
||||
int field2; // GOOD
|
||||
|
||||
C2() {
|
||||
this = field2 and
|
||||
this = 0
|
||||
}
|
||||
|
||||
int getField() { result = field2 }
|
||||
}
|
||||
|
||||
class C3 extends int {
|
||||
C1 field; // GOOD (overridden)
|
||||
|
||||
C3() { this = field }
|
||||
}
|
||||
|
||||
class C4 extends C3 {
|
||||
override C2 field; // GOOD (overriding)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
queries/style/FieldOnlyUsedInCharPred.ql
|
||||
Reference in New Issue
Block a user