testsuites/danmar-verify: fix syntax errors

This commit is contained in:
Daniel Marjamäki 2020-01-14 10:28:05 +01:00
parent dfbf347912
commit 434b506e58
2 changed files with 22 additions and 14 deletions

View File

@ -1,6 +1,8 @@
// make USE_Z3=yes // make USE_Z3=yes
// ./cppcheck --verify --inline-suppr --enable=information test/testsuites/danmar-verify/divbyzero.cpp // ./cppcheck --verify --inline-suppr --enable=information test/testsuites/danmar-verify/divbyzero.cpp
#include <stdio.h>
#include <map>
struct S { int x; }; struct S { int x; };
@ -8,61 +10,65 @@ int globalvar;
void dostuff(); void dostuff();
void callfunc1() { int callfunc1() {
int x = 16; int x = 16;
scanf("%i\n", &x); scanf("%i\n", &x);
// cppcheck-suppress verificationDivByZero // cppcheck-suppress verificationDivByZero
return 100000 / x; return 100000 / x;
} }
void float1(float f) { int float1(float f) {
// cppcheck-suppress verificationDivByZero // cppcheck-suppress verificationDivByZero
return 100000 / (int)f; return 100000 / (int)f;
} }
void float2(float f) { float float2(float f) {
// cppcheck-suppress verificationDivByZeroFloat // cppcheck-suppress verificationDivByZeroFloat
return 100000 / f; return 100000 / f;
} }
void functionCall() { int functionCall() {
#ifdef __clang__
return 0;
#else
// cppcheck-suppress verificationDivByZero // cppcheck-suppress verificationDivByZero
return 100000 / unknown_function(); return 100000 / unknown_function();
#endif
} }
void globalVar1() { int globalVar1() {
// cppcheck-suppress verificationDivByZero // cppcheck-suppress verificationDivByZero
return 100000 / globalvar; return 100000 / globalvar;
} }
void globalVar1() { int globalVar2() {
globalvar = 123; globalvar = 123;
dostuff(); dostuff();
// cppcheck-suppress verificationDivByZero // cppcheck-suppress verificationDivByZero
return 100000 / globalvar; return 100000 / globalvar;
} }
void pointer1(int *p) { int pointer1(int *p) {
// cppcheck-suppress verificationDivByZero // cppcheck-suppress verificationDivByZero
return 100000 / *p; return 100000 / *p;
} }
void pointer2(int *p) { int pointer2(int *p) {
// cppcheck-suppress verificationDivByZero // cppcheck-suppress verificationDivByZero
return 100000 / p[32]; return 100000 / p[32];
} }
void stdmap(std::map<int,int> &data) { int stdmap(std::map<int,int> &data) {
// cppcheck-suppress verificationDivByZero // cppcheck-suppress verificationDivByZero
return 100000 / data[43]; return 100000 / data[43];
} }
void struct1(struct S *s) { int struct1(struct S *s) {
// cppcheck-suppress verificationDivByZero // cppcheck-suppress verificationDivByZero
return 100000 / s->x; return 100000 / s->x;
} }
void trycatch() { int trycatch() {
int x = 0; int x = 0;
try { try {
dostuff(); dostuff();

View File

@ -2,6 +2,8 @@
// make USE_Z3=yes // make USE_Z3=yes
// ./cppcheck --verify --inline-suppr --enable=information test/testsuites/danmar-verify/uninit.c // ./cppcheck --verify --inline-suppr --enable=information test/testsuites/danmar-verify/uninit.c
#include <string.h>
int array1() { int array1() {
int a[10]; int a[10];
a[0] = 0; a[0] = 0;
@ -16,7 +18,7 @@ int array2() {
return a[2][3]; return a[2][3];
} }
void local1() { int local1() {
int x; int x;
// cppcheck-suppress verificationUninit // cppcheck-suppress verificationUninit
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
@ -28,8 +30,8 @@ int pointer1(int *p) {
return *p; return *p;
} }
void pointer2(char *p) { int pointer2(char *p) {
// cppcheck-suppress verificationUninitArg // cppcheck-suppress verificationUninitArg
strlen(p); return strlen(p);
} }