From: Matthias Braun Date: Mon, 2 Jul 2007 13:48:35 +0000 (+0000) Subject: fixed lots of warnings in testprograms X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=0c431a4d7b710e58876a3de85074f7217924ab4c;p=libfirm fixed lots of warnings in testprograms [r14882] --- diff --git a/ir/be/test/Arrays.c b/ir/be/test/Arrays.c index 082e9edeb..0e931a8b7 100644 --- a/ir/be/test/Arrays.c +++ b/ir/be/test/Arrays.c @@ -1,4 +1,5 @@ #include +#include struct Arr2Object { int a[10]; @@ -36,7 +37,6 @@ static void pass_array_test(struct ArrObject *a, int a_len) int main(int argc, char *argv[]) { int i, j, bi; struct ArrObject ao[10]; - struct ArrObject aob; struct Arr2Object a2o[2]; struct Arr2Object a2; diff --git a/ir/be/test/Field.c b/ir/be/test/Field.c index a78d66842..7c2e66743 100644 --- a/ir/be/test/Field.c +++ b/ir/be/test/Field.c @@ -2,7 +2,7 @@ * $Id$ */ -//#include +#include struct s { int a; diff --git a/ir/be/test/ForTest.c b/ir/be/test/ForTest.c index 3ca67fbc1..945ab9faf 100644 --- a/ir/be/test/ForTest.c +++ b/ir/be/test/ForTest.c @@ -12,19 +12,8 @@ typedef int boolean; #define true 1 #define false 0 -static void piff(void) { - int i, j, x, delta_x; - - delta_x = 2; - j = 0; - x = 0; - for (i = 0, x = 0; i < 1000; i++, x += delta_x) { - j += x; - } -} - static int simpleloop (int a, int b) { - int i, j, delta_x, x; + int i, j; boolean loopfinal = true; for(i = 0; (i < 10) && loopfinal; i++) { @@ -43,8 +32,6 @@ static int simpleloop (int a, int b) { } int main (int argc, char *argv[]) { - int i, j; - printf("ForTest.c\n"); simpleloop(3, 10); diff --git a/ir/be/test/GlobalCseTest.c b/ir/be/test/GlobalCseTest.c index 237328c24..a8d621302 100644 --- a/ir/be/test/GlobalCseTest.c +++ b/ir/be/test/GlobalCseTest.c @@ -4,6 +4,7 @@ // $Id$ // // Testprogram to test GCC-firm : GlobalCseTest.c +#include int m(int a) { int b; diff --git a/ir/be/test/HeapSort.c b/ir/be/test/HeapSort.c index 3879b7801..a3c08266f 100644 --- a/ir/be/test/HeapSort.c +++ b/ir/be/test/HeapSort.c @@ -107,7 +107,7 @@ void heapaufbau2(int *a, int *b, int len) { * Heap-Methoden und gibt das sortierte Feld zurück. */ int *heapsort(int *b, int len) { - int i, k; + int k; int *c; int *a; diff --git a/ir/be/test/Local.c b/ir/be/test/Local.c index c978b667e..50767a498 100644 --- a/ir/be/test/Local.c +++ b/ir/be/test/Local.c @@ -1,3 +1,5 @@ +#include + // // GCC-firm Project // diff --git a/ir/be/test/Pdg.c b/ir/be/test/Pdg.c index 238dda0bc..55de027c7 100644 --- a/ir/be/test/Pdg.c +++ b/ir/be/test/Pdg.c @@ -12,6 +12,7 @@ int main(int argc, char *argv[]) { printf("Pdg.c\n"); i = 1; + k = 0; while (i < 10) { j = i + 1; if (j == 7) @@ -21,5 +22,6 @@ int main(int argc, char *argv[]) { i = i + 1; } + (void) k; return 0; } diff --git a/ir/be/test/Queens.c b/ir/be/test/Queens.c index c0f4db54b..f50bcfe36 100644 --- a/ir/be/test/Queens.c +++ b/ir/be/test/Queens.c @@ -38,43 +38,48 @@ boolean place_ok (int i) { int j = 0; boolean res; + printf("POK: %d\n", i); + while (j < i) { if ((row[j] == row[i]) || ((myabs(row[i]-row[j])) == (i-j))) { + printf("F\n"); res = false; return(res); } j = j+1; } + printf("T\n"); res = true; return(res); } int solve (int n) { - // return the number of solutions to the n-queens problem - int c = 0; - int res = 0; - - row = (void *)malloc(sizeof(*row) * n); - row[0] = -1; - while (c >= 0) { - row[c] = row[c]+1; - while ((row[c] < n) && (!place_ok(c))) { - row[c] = row[c]+1; - } - if (row[c] < n) { // successfully placed at (c,row[c]) - if (c == n-1) - res = res+1; - else { - c = c+1; - row[c] = -1; - } - } - else // dead end, track back - c = c-1; - } - free(row); - - return(res); + // return the number of solutions to the n-queens problem + int c = 0; + int res = 0; + + row = (void *)malloc(sizeof(*row) * n); + row[0] = -1; + while (c >= 0) { + row[c] = row[c]+1; + while ((row[c] < n) && (!place_ok(c))) { + row[c] = row[c]+1; + } + printf("RC: %d\n", row[c]); + if (row[c] < n) { // successfully placed at (c,row[c]) + if (c == n-1) + res = res+1; + else { + c = c+1; + row[c] = -1; + } + } + else // dead end, track back + c = c-1; + } + free(row); + + return(res); } static void usage (const char *progname) { diff --git a/ir/be/test/Sieve.c b/ir/be/test/Sieve.c index fb2e4189a..25c4213ae 100644 --- a/ir/be/test/Sieve.c +++ b/ir/be/test/Sieve.c @@ -28,7 +28,7 @@ static void mark_count(int c) { static void runSieve(void) { int ITERATIONS = 100000; boolean *flags; - int i, prime, k, iter, p; + int i, prime, k; int iterations = 0; int count; @@ -58,8 +58,6 @@ static void runSieve(void) { } int main(int argc, char *argv[]) { - int i; - printf("Sieve.c\n"); if (argc <= 1) { diff --git a/ir/be/test/Switcher.c b/ir/be/test/Switcher.c index aee52de50..cdecf7dc5 100644 --- a/ir/be/test/Switcher.c +++ b/ir/be/test/Switcher.c @@ -15,10 +15,6 @@ static void print_int(int i) { printf(" %d\n", i); } -static int id(int i) { - return(i); -} - // standard switch with 1 case static void switch1(int i) { switch(i) { @@ -141,13 +137,14 @@ static void double_switch(int i) { int main (int argc, char *argv[]) { printf("Switcher.c\n"); - printf(" must print:\n 0\n 2\n 0\n 3\n -1\n 2\n is 16\n multiple of 4\n\n"); + printf(" must print:\n 0\n 2\n 0\n 3\n -1\n 2\n 5\n is 16\n multiple of 4\n\n"); switch1(0); switch2(2); switch3(0); switch4(5); switch5(0); switch6(2); + switch7(3); double_switch(16); return 0; diff --git a/ir/be/test/ack/t7.c b/ir/be/test/ack/t7.c index 69457f293..56648dd76 100644 --- a/ir/be/test/ack/t7.c +++ b/ir/be/test/ack/t7.c @@ -135,6 +135,7 @@ int n; itoa(t,cht); write(1,cht,strlen(cht)); write(1,pp6,strlen(pp6)); + abort(); } diff --git a/ir/be/test/arr_init.c b/ir/be/test/arr_init.c index fff9a7c68..2c3f26f21 100644 --- a/ir/be/test/arr_init.c +++ b/ir/be/test/arr_init.c @@ -1,3 +1,5 @@ +#include + int arr0[] = { 0, 1, 2, 3 }; int arr1[4] = { 3, 2, 1 }; int arrm[3][4] = { {1}, {2,3,4,5}, {6, 7, 8 } }; diff --git a/ir/be/test/array_type.c b/ir/be/test/array_type.c index 6a6a50893..668b02e5d 100644 --- a/ir/be/test/array_type.c +++ b/ir/be/test/array_type.c @@ -1,3 +1,5 @@ +#include + int foo[255][4]; int bar[4] = { 0, 1, 2, 3 }; diff --git a/ir/be/test/bitfield.c b/ir/be/test/bitfield.c index 5703c68ab..d92d0ca59 100644 --- a/ir/be/test/bitfield.c +++ b/ir/be/test/bitfield.c @@ -1,3 +1,5 @@ +#include + struct a { unsigned int i:1; }; diff --git a/ir/be/test/compress95.c b/ir/be/test/compress95.c index 3b3ed0091..352db5e89 100644 --- a/ir/be/test/compress95.c +++ b/ir/be/test/compress95.c @@ -202,6 +202,7 @@ static char rcs_ident[] = "$Header$"; #include #include +#include #ifdef VMS #include #include @@ -355,8 +356,7 @@ unsigned char *OutBuff; spec_select_action(char* from_buf, int from_count, int action, char* to_buf) { - char *cp, *rindex(), *malloc(); - struct stat statbuf; + char *rindex(); #ifdef SYSV void onintr(), oops(); #else diff --git a/ir/be/test/convtest.c b/ir/be/test/convtest.c index f4a973001..3a323052e 100644 --- a/ir/be/test/convtest.c +++ b/ir/be/test/convtest.c @@ -12,7 +12,7 @@ int convtest_func(char c, short s, int i, float f, double d) { short is = s + i; short fs = s + f; short ds = s + d; - int ti = i + s; + //int ti = i + s; int fi = i + f; int di = i + d; float df = d + f; diff --git a/ir/be/test/dblstruct.c b/ir/be/test/dblstruct.c index 706e65bd8..b59f39985 100644 --- a/ir/be/test/dblstruct.c +++ b/ir/be/test/dblstruct.c @@ -1,3 +1,5 @@ +#include + typedef struct TypeToken { int Handle; diff --git a/ir/be/test/fehler10.c b/ir/be/test/fehler10.c index 6163e9d8e..fc39453f7 100644 --- a/ir/be/test/fehler10.c +++ b/ir/be/test/fehler10.c @@ -1,3 +1,5 @@ +#include + void a(void); void b(void); diff --git a/ir/be/test/fehler11.c b/ir/be/test/fehler11.c index 2412638d9..ab7b91d40 100644 --- a/ir/be/test/fehler11.c +++ b/ir/be/test/fehler11.c @@ -1,3 +1,5 @@ +#include + int main(void) { long long a = 0x0123456789012345; diff --git a/ir/be/test/fehler14.c b/ir/be/test/fehler14.c index fc2e38200..97be59b75 100644 --- a/ir/be/test/fehler14.c +++ b/ir/be/test/fehler14.c @@ -1,3 +1,5 @@ +#include + unsigned int c = 0xffffffff; unsigned short b; diff --git a/ir/be/test/gcd.c b/ir/be/test/gcd.c index 2259c556f..00d764563 100644 --- a/ir/be/test/gcd.c +++ b/ir/be/test/gcd.c @@ -19,7 +19,7 @@ int gcd(int a, int b) int main(int argc, char** argv) { - int a = 49, b = 35, i, g; + int a = 49, b = 35, i, g = 0; if(argc > 2) { a = atoi(argv[1]); diff --git a/ir/be/test/harness.c b/ir/be/test/harness.c index 4ea62e245..64f2ae7e9 100644 --- a/ir/be/test/harness.c +++ b/ir/be/test/harness.c @@ -36,7 +36,6 @@ fill_text_buffer(int count, char start_char, char* text_buffer) long int total; /* normalization */ int i,j; /* array indexers */ char c1,c2; /* character holders for level-three search */ - int writecount ; /* Number of characters written */ int bufindex; /* @@ -219,31 +218,31 @@ char orig_text_buffer[BUFFERSIZE], comp_text_buffer[BUFFERSIZE], new_text_buffer int main(int argc, char *argv[]) { -int count, i, oper; -int comp_count, new_count; +int count, i; +int new_count; char start_char; -int N; -char C; +int comp_count = 0; printf("SPEC 129.compress harness\n"); - // for now... - return 0; - scanf("%i %c %li", &count, &start_char, &seedi); + //scanf("%i %c %li", &count, &start_char, &seedi); + count = 10; + start_char=10; + seedi = 12345; printf("Initial File Size:%i Start character:%c\n", count, start_char, seedi); fill_text_buffer(count, start_char, orig_text_buffer); for (i = 1; i <= 25; i++) { new_count=add_line(orig_text_buffer, count, i, start_char); count=new_count; - oper=COMPRESS; + //oper=COMPRESS; printf("The starting size is: %d\n", count); //comp_count=spec_select_action(orig_text_buffer, count, oper, comp_text_buffer); printf("The compressed size is: %d\n", comp_count); - oper=UNCOMPRESS; + //oper=UNCOMPRESS; //new_count=spec_select_action(comp_text_buffer, comp_count, oper, new_text_buffer); printf("The compressed/uncompressed size is: %d\n", new_count); - compare_buffer(orig_text_buffer, count, new_text_buffer, new_count); + //compare_buffer(orig_text_buffer, count, new_text_buffer, new_count); } /* Remove comments for Debugging */ /* diff --git a/ir/be/test/kahansum.c b/ir/be/test/kahansum.c index 79d6744a5..d02c5a60a 100644 --- a/ir/be/test/kahansum.c +++ b/ir/be/test/kahansum.c @@ -1,3 +1,5 @@ +#include + float kahanSum(const float A[], int n) { float sum = 0.0, C = 0.0, Y, T; int i; diff --git a/ir/be/test/nested_loops.c b/ir/be/test/nested_loops.c index 685054b54..300eefa2d 100644 --- a/ir/be/test/nested_loops.c +++ b/ir/be/test/nested_loops.c @@ -1,7 +1,11 @@ +#include + +int k = 0; + static void send_via_write() { - int r2, fd; + int r2 = k, fd; if ( r2 <= 2147483647 ) { } diff --git a/ir/be/test/nested_loops2.c b/ir/be/test/nested_loops2.c index 40781d32d..ad805cb95 100644 --- a/ir/be/test/nested_loops2.c +++ b/ir/be/test/nested_loops2.c @@ -1,6 +1,10 @@ +#include + +int k = 0; + static void send_via_write() { - int r2; + int r2 = k; if ( r2 <= 2147483647 ) { } diff --git a/ir/be/test/ns.c b/ir/be/test/ns.c index f727bbf4f..a6306c85e 100644 --- a/ir/be/test/ns.c +++ b/ir/be/test/ns.c @@ -1,3 +1,5 @@ +#include + #define MAX_OPERANDS 3 typedef unsigned short uint16_t; diff --git a/ir/be/test/optest.h b/ir/be/test/optest.h index e36cdc5b0..67428b9f8 100644 --- a/ir/be/test/optest.h +++ b/ir/be/test/optest.h @@ -1,3 +1,5 @@ +#include + #ifndef TESTANZ #define TESTANZ 21 #define IMM 23 @@ -5,8 +7,8 @@ #define test16_1 42 #define test16_2 11 #define test16_shift 7 -#define test32_1 0x001200AB -#define test32_2 0x00341501 +#define test32_1 (T) 0x001200AB +#define test32_2 (T) 0x00341501 #define test32_shift 5 #define test32_s 7 #endif diff --git a/ir/be/test/stmt_expr.c b/ir/be/test/stmt_expr.c index 2c439ba0b..ffffbf69a 100644 --- a/ir/be/test/stmt_expr.c +++ b/ir/be/test/stmt_expr.c @@ -1,3 +1,5 @@ +#include + #define maxint(a,b) \ ({int _a = (a), _b = (b); _a > _b ? _a : _b; }) diff --git a/ir/be/test/strenght_red.c b/ir/be/test/strenght_red.c index 0bc9cd05e..7ac1bf3da 100644 --- a/ir/be/test/strenght_red.c +++ b/ir/be/test/strenght_red.c @@ -1,3 +1,5 @@ +#include + int main() { int i; diff --git a/ir/be/test/struct.c b/ir/be/test/struct.c index 517ea8b81..5559ece8e 100644 --- a/ir/be/test/struct.c +++ b/ir/be/test/struct.c @@ -1,4 +1,4 @@ -//#include +#include struct A { int x; diff --git a/ir/be/test/switch_test.c b/ir/be/test/switch_test.c index bb3869cdc..d1c7f97a2 100644 --- a/ir/be/test/switch_test.c +++ b/ir/be/test/switch_test.c @@ -1,3 +1,5 @@ +#include + int test(int a) { int b = 0xff; diff --git a/ir/be/test/trivial_add.c b/ir/be/test/trivial_add.c index a4fc8c913..80ec2f68d 100644 --- a/ir/be/test/trivial_add.c +++ b/ir/be/test/trivial_add.c @@ -1,3 +1,5 @@ +#include + /* * Proj's of the arguments * Simple DF node. diff --git a/ir/be/test/trivial_div.c b/ir/be/test/trivial_div.c index b0433820a..466175599 100644 --- a/ir/be/test/trivial_div.c +++ b/ir/be/test/trivial_div.c @@ -1,3 +1,4 @@ +#include /* * Proj out of DF node diff --git a/ir/be/test/trivial_max.c b/ir/be/test/trivial_max.c index c2aaf3e5b..2e0acb6ee 100644 --- a/ir/be/test/trivial_max.c +++ b/ir/be/test/trivial_max.c @@ -1,3 +1,4 @@ +#include /* * Control flow divertion in an if statement. diff --git a/ir/be/test/trivial_sum_upto.c b/ir/be/test/trivial_sum_upto.c index 5f7260610..6c57225da 100644 --- a/ir/be/test/trivial_sum_upto.c +++ b/ir/be/test/trivial_sum_upto.c @@ -1,3 +1,4 @@ +#include /* * A simple loop diff --git a/ir/be/test/trivial_two_times.c b/ir/be/test/trivial_two_times.c index 4eb6c4235..ed949cda0 100644 --- a/ir/be/test/trivial_two_times.c +++ b/ir/be/test/trivial_two_times.c @@ -1,3 +1,5 @@ +#include + /* * Proj's of the arguments * Simple DF node. diff --git a/ir/be/test/valist.c b/ir/be/test/valist.c index da9c357de..a75c0b50f 100644 --- a/ir/be/test/valist.c +++ b/ir/be/test/valist.c @@ -1,3 +1,5 @@ +#include + #ifdef __GNUC__ #define va_start(v,l) __builtin_va_start(v,l) #define va_end(v) __builtin_va_end(v) diff --git a/ir/be/test/vandrunen.c b/ir/be/test/vandrunen.c index a81a3d6c6..3012e6638 100644 --- a/ir/be/test/vandrunen.c +++ b/ir/be/test/vandrunen.c @@ -1,3 +1,5 @@ +#include + int T6, T10, T13; /*