tweak synthetic tests

This commit is contained in:
Daniel Marjamäki 2016-11-03 20:16:49 +01:00
parent 506d1ed68d
commit 6e9346323c
3 changed files with 69 additions and 46 deletions

View File

@ -9,93 +9,116 @@ int getValue(void); // unknown int value
// arg
// -------------------------------------
void bug_arg_in_if(int a) {
if (a>=__LINE__)
void arg_in_if(int a) {
if (a>=100)
buf[a] = 0; // BUG
}
void bug_arg_before_if(int a) {
buf[a] = 0; // BUG
if (a==__LINE__) {}
void arg_before_if(int a) {
buf[a] = 0; // WARNING
if (a==100) {}
}
void bug_arg_after_if(int a) {
if (a==__LINE__) {}
buf[a] = 0; // BUG
void arg_after_if(int a) {
if (a==100) {}
buf[a] = 0; // WARNING
}
// var
// -------------------------------------
void bug_var(void) {
int x = __LINE__;
void var(void) {
int x = 100;
buf[x] = 0; // BUG
}
void bug_var_in_switch(void) {
void var_in_for(void) {
int x;
for (x = 0; x<100; x++) {
buf[x] = 0; // BUG
}
}
void var_after_for(void) {
int x;
for (x = 0; x<100; x++) {}
buf[x] = 0; // BUG
}
void var_in_switch(void) {
int x = getValue();
switch (x) {
case __LINE__:
case 100:
buf[x] = 0; // BUG
break;
}
}
void bug_var_after_switch(void) {
void var_before_switch(void) {
int x = getValue();
buf[x] = 0; // WARNING
switch (x) {
case __LINE__:
case 100:
break;
}
buf[x] = 0; // BUG
}
void bug_var_after_while(void) {
int x = 0;
while (x<=__LINE__)
x++;
buf[x] = 0; // BUG
void var_after_switch(void) {
int x = getValue();
switch (x) {
case 100:
break;
}
buf[x] = 0; // WARNING
}
void bug_var_in_while(void) {
void var_in_while(void) {
int x = 0;
while (x<__LINE__) {
while (x<100) {
buf[x] = 0; // BUG
x++;
}
}
void var_after_while(void) {
int x = 0;
while (x<100)
x++;
buf[x] = 0; // BUG
}
// arg+var
// -------------------------------------
void bug_arg_var_assign_in_if(int a) {
void arg_var_assign_in_if(int a) {
int x = 0;
if (a==0)
x = __LINE__;
buf[x] = 0; // BUG
x = 100;
buf[x] = 0; // WARNING
}
void bug_arg_var_second_if(int a) {
void arg_var_in_while_1(int a) {
int x = 0;
if (a==0)
x = __LINE__;
if (a+1==1)
buf[x] = 0; // BUG
}
void bug_arg_var_after_while(int a) {
int x = 0;
if (a == __LINE__) {}
while (x<a)
x++;
buf[x] = 0; // BUG
}
void bug_arg_var_in_while(int a) {
int x = 0;
if (a == __LINE__) {}
if (a == 100) {}
while (x<a) {
buf[x] = 0; // BUG
buf[x] = 0; // WARNING
x++;
}
}
void arg_var_in_while_2(int a) {
int x = 0;
while (x<a) {
buf[x] = 0; // WARNING
x++;
}
if (a == 100) {}
}
void arg_var_after_while(int a) {
int x = 0;
if (a == 100) {}
while (x<a)
x++;
buf[x] = 0; // WARNING
}

View File

@ -2,7 +2,7 @@
int TestData[100];
void test_function_par(int par) {
void test_function_par1(int par) {
TestData[par] = 0;
}
void test_function_par2(int x, int y) {

View File

@ -5,6 +5,6 @@ int null_pointer() { int *p = 0; return *p; }
int *pointer_arithmetic() { static int buf[10]; return buf + 100; }
int shift_overrun(int x) { return x << 123; }
int shift_negative() { return -1 << 1; }
int signed_int_overrun() { int x = ~0; return x * 2; }
int signed_int_overrun() { int intmax = (~0U) >> 1; return intmax * 2; }
void string_literal() { *((char *)"hello") = 0; }
int uninit() { int x; return x + 2; }