diff --git a/test/synthetic/Makefile b/test/synthetic/Makefile index 31eaa191d..916cb3108 100644 --- a/test/synthetic/Makefile +++ b/test/synthetic/Makefile @@ -2,8 +2,7 @@ ifndef CC CC=gcc endif - -all: controlflow.o data.o functions.o uninit.o +all: controlflow.o data.o functions.o controlflow.o: controlflow.c $(CC) -c controlflow.c @@ -14,8 +13,5 @@ data.o: data.c functions.o: functions.c $(CC) -c functions.c -uninit.o: uninit.c - $(CC) -std=gnu99 -c uninit.c - clean: rm -rf controlflow.o data.o functions.o uninit.o diff --git a/test/synthetic/data.c b/test/synthetic/data.c index c6f1d5909..03cb207a7 100644 --- a/test/synthetic/data.c +++ b/test/synthetic/data.c @@ -1,45 +1,68 @@ int TestData[10]; -#define TEST(DATA) DATA=1000;TestData[DATA]=0; DATA=0;TestData[0]=100/(DATA); int global; void test_global() { - TEST(global); + global = 1000; + TestData[global] = 0; } int global_array[10]; void test_global_array() { - TEST(global_array[3]); + global_array[3] = 1000; + TestData[global_array[3]] = 0; } int *global_pointer; void test_global_pointer() { - TEST(*global_pointer); + *global_pointer = 1000; + TestData[*global_pointer] = 0; } void test_local() { int local; - TEST(local); + local = 1000; + TestData[local] = 0; } void test_local_array() { int local_array[10]; - TEST(local_array[3]); + local_array[3] = 1000; + TestData[local_array[3]] = 0; } -void test_local_pointer() { +void test_local_alias_1() { int local; - int *local_pointer = &local; - TEST(*local_pointer); + int *local_alias = &local; + *local_alias = 1000; + TestData[*local_alias] = 0; } +void test_local_alias_2() { + int local; + int *local_alias = &local; + local = 1000; + TestData[*local_alias] = 0; +} -struct S { - int member; +struct ABC { + int a; + int b[10]; + int c; }; -void test_struct_member(struct S *s) { - TEST(s->member); + +void test_struct_member_init() { + struct ABC abc = {1000,{0},3}; + TestData[abc.a] = 0; } +void test_struct_member_assign(struct ABC *abc) { + abc->a = 1000; + TestData[abc->a] = 0; +} +void test_struct_arraymember(struct ABC *abc) { + abc->b[3] = 1000; + TestData[abc->b[3]] = 0; +} diff --git a/test/synthetic/uninit.c b/test/synthetic/uninit.c deleted file mode 100644 index 496d23cab..000000000 --- a/test/synthetic/uninit.c +++ /dev/null @@ -1,61 +0,0 @@ - -// catch uninit variables.. - -#define AB1(A,B) A##B -#define AB2(A,B) AB1(A,B) -#define USE_INT_X(STMT) void AB2(use,__LINE__) (void) { int x; STMT; } - -void dostuff(int); - -// Bugs -USE_INT_X(dostuff(x)) -USE_INT_X(dostuff(2+x)) -USE_INT_X(x++) -USE_INT_X(x--) -USE_INT_X(++x) -USE_INT_X(--x) -USE_INT_X(-x) -USE_INT_X(+x) -USE_INT_X(!x) -USE_INT_X(~x) -USE_INT_X(if (x>0)) -USE_INT_X(if (x>=0)) -USE_INT_X(if (x<=0)) -USE_INT_X(if (x<0)) -USE_INT_X(if (x==0)) -USE_INT_X(if (x==0)) -USE_INT_X(for (int a=x; a<10; a++)) -USE_INT_X(for (int a=0; a>1) -USE_INT_X(x+=1) -USE_INT_X(x-=1) -USE_INT_X(x*=1) -USE_INT_X(x/=1) -USE_INT_X(x%=1) -USE_INT_X(x&=1) -USE_INT_X(x|=1) -USE_INT_X(x^=1) -USE_INT_X(x<<=1) -USE_INT_X(x>>=1) -USE_INT_X(1?x:1) -USE_INT_X(1&&x) -USE_INT_X(x=*(&x)+1) -USE_INT_X(int*p=&x; dostuff(*p)) - -// No bugs -USE_INT_X(x=0) -USE_INT_X(0?x:1) -USE_INT_X(0&&x) -USE_INT_X(int*p=&x; *p=0; dostuff(x)) - -