mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
C++: add testcases for UninitializedLocal.ql
This commit is contained in:
@@ -14,3 +14,7 @@
|
||||
| test.cpp:378:9:378:11 | val | The variable $@ may not be initialized at this access. | test.cpp:359:6:359:8 | val | val |
|
||||
| test.cpp:417:10:417:10 | j | The variable $@ may not be initialized at this access. | test.cpp:414:9:414:9 | j | j |
|
||||
| test.cpp:436:9:436:9 | j | The variable $@ may not be initialized at this access. | test.cpp:431:9:431:9 | j | j |
|
||||
| test.cpp:454:2:454:2 | x | The variable $@ may not be initialized at this access. | test.cpp:452:6:452:6 | x | x |
|
||||
| test.cpp:460:7:460:7 | x | The variable $@ may not be initialized at this access. | test.cpp:458:6:458:6 | x | x |
|
||||
| test.cpp:467:2:467:2 | x | The variable $@ may not be initialized at this access. | test.cpp:464:6:464:6 | x | x |
|
||||
| test.cpp:474:7:474:7 | x | The variable $@ may not be initialized at this access. | test.cpp:471:6:471:6 | x | x |
|
||||
|
||||
@@ -435,3 +435,41 @@ int test38() {
|
||||
|
||||
return j; // BAD
|
||||
}
|
||||
|
||||
void test39() {
|
||||
int x;
|
||||
|
||||
x; // GOOD, in void context
|
||||
}
|
||||
|
||||
void test40() {
|
||||
int x;
|
||||
|
||||
(void)x; // GOOD, explicitly cast to void
|
||||
}
|
||||
|
||||
void test41() {
|
||||
int x;
|
||||
|
||||
x++; // BAD
|
||||
}
|
||||
|
||||
void test42() {
|
||||
int x;
|
||||
|
||||
void(x++); // BAD
|
||||
}
|
||||
|
||||
void test43() {
|
||||
int x;
|
||||
int y = 1;
|
||||
|
||||
x + y; // BAD
|
||||
}
|
||||
|
||||
void test44() {
|
||||
int x;
|
||||
int y = 1;
|
||||
|
||||
void(x + y); // BAD
|
||||
}
|
||||
Reference in New Issue
Block a user