fixed lots of warnings in testprograms
[libfirm] / ir / be / test / cfoptbug.c
1 #include <stdio.h>
2 #include <assert.h>
3
4 struct list {
5         struct list *next;
6         int val;
7 };
8
9 struct list l = { NULL, 5 };
10 struct list *sptr = &l;
11 struct list l2 = { NULL, 42 };
12 struct list *sptr2 = &l2;
13
14 struct list *test(int n)
15 {
16         struct list *ptr1;
17         struct list *ptr2;
18         int sum = 0;
19
20         if(n == 0) {
21                 ptr1 = sptr;
22         } else {
23                 ptr1 = sptr2;
24         }
25
26         for(ptr2 = ptr1; ptr2 != NULL; ptr2 = ptr2->next) {
27                 sum += ptr2->val;
28         }
29         printf("Sum: %d\n", sum);
30
31         return ptr1;
32 }
33
34 int main(int argc, char **argv)
35 {
36         struct list *ptr1 = test(0);
37         struct list *ptr2 = test(1);
38
39         assert(ptr1 == sptr);
40         assert(ptr2 == sptr2);
41
42         return 0;
43 }