C++: Add tests and accept test changes.

This commit is contained in:
Mathias Vorreiter Pedersen
2024-05-20 09:01:42 +01:00
parent e8b9d7e6fa
commit df24e5982a
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
| test.cpp:3:11:3:15 | local | Variable 'local' is not initialized. |
| test.cpp:12:5:12:24 | uninitialised_global | Variable 'uninitialised_global' is not initialized. |

View File

@@ -0,0 +1 @@
Critical/NotInitialised.ql

View File

@@ -0,0 +1,20 @@
void test1() {
int local;
int x = local; // BAD
static int static_local;
int y = static_local; // GOOD
int initialised = 42;
int z = initialised; // GOOD
}
int uninitialised_global; // BAD
static int uninitialised_static_global; // GOOD
int initialized_global = 0; // GOOD
void test2() {
int a = uninitialised_global;
int b = uninitialised_static_global;
int c = initialized_global;
}