testsuites/danmar-verify: Add divbyzero tests

This commit is contained in:
Daniel Marjamäki 2020-01-09 10:48:43 +01:00
parent 0b7649ca9b
commit 0becff9d7f
1 changed files with 19 additions and 0 deletions

View File

@ -6,6 +6,8 @@ struct S { int x; };
int globalvar;
void dostuff();
void callfunc1() {
int x = 16;
scanf("%i\n", &x);
@ -33,6 +35,13 @@ void globalVar1() {
return 100000 / globalvar;
}
void globalVar1() {
globalvar = 123;
dostuff();
// cppcheck-suppress verificationDivByZero
return 100000 / globalvar;
}
void pointer1(int *p) {
// cppcheck-suppress verificationDivByZero
return 100000 / *p;
@ -52,3 +61,13 @@ void struct1(struct S *s) {
// cppcheck-suppress verificationDivByZero
return 100000 / s->x;
}
void trycatch() {
int x = 0;
try {
dostuff();
x = 1;
} catch (...) {}
// cppcheck-suppress verificationDivByZero
return 100000 / x;
}