Skip several analyzer socket tests on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / pr110830.c
blobf5a39b7a067e93e652c284c0cc1fddd4f0d7f668
1 typedef __SIZE_TYPE__ size_t;
3 void free(void *);
4 void *malloc(__SIZE_TYPE__);
6 extern int ext();
8 void test_supersedes ()
10 int *p = (int *)malloc(sizeof(int));
11 free(p);
12 int x = *p + 4; /* { dg-warning "use after 'free' of 'p'" } */
13 /* { dg-bogus "use of uninitialized value '\\*p" "" { target *-*-* } .-1 } */
16 int *called_by_test0()
18 int *p = 0;
19 if (ext())
21 p = (int *)malloc(sizeof(int));
22 free(p);
23 return p;
25 else
26 return (int *)malloc(sizeof(int));
29 void test0()
31 int *y = called_by_test0();
32 int x = 0;
33 if (y != 0)
34 x = *y; /* { dg-warning "use after 'free' of 'y'" } */
35 /* { dg-warning "use of uninitialized value '\\*y'" "don't supersede warnings with incompatible cfg path" { target *-*-* } .-1 } */
36 free(y); /* { dg-warning "double-'free'" } */
39 void test1()
41 int *p = 0;
42 if (ext())
44 p = (int *)malloc(sizeof(int));
45 free(p);
47 else
48 p = (int *)malloc(sizeof(int));
50 int x = 0;
51 if (p != 0)
52 x = *p; /* { dg-warning "use after 'free' of 'p'" } */
53 /* { dg-warning "use of uninitialized value '\\*p'" "don't supersede warnings with incompatible cfg path" { target *-*-* } .-1 } */
54 free(p); /* { dg-warning "double-'free'" } */
57 void test2()
59 int *p = 0;
60 p = (int *)malloc(sizeof(int));
61 if (ext())
62 free(p);
64 int x = 0;
65 if (p != 0)
66 x = *p; /* { dg-warning "use after 'free' of 'p'" } */
67 /* { dg-warning "use of uninitialized value '\\*p'" "don't supersede warnings with incompatible cfg path" { target *-*-* } .-1 } */
68 free(p); /* { dg-warning "double-'free'" } */
71 void test3()
73 int *p = 0;
74 p = (int *)malloc(sizeof(int));
75 int i = 100;
76 while (i--)
78 int x = 0;
79 if (p != 0)
80 x = *p; /* { dg-warning "use after 'free' of 'p'" } */
81 /* { dg-warning "use of uninitialized value '\\*p'" "don't supersede warnings with incompatible cfg path" { target *-*-* } .-1 } */
82 p = (int *)malloc(sizeof(int));
83 free(p);
86 free(p); /* { dg-warning "double-'free'" } */
90 void test4()
92 int *p = 0;
93 if (ext())
95 p = (int *) malloc(sizeof(int));
96 if (ext () > 5)
98 mal:
99 free (p);
102 else {
103 goto mal;
106 int x = 0;
107 if (p != 0)
108 x = *p; /* { dg-warning "use after 'free' of 'p'" } */
109 /* { dg-warning "use of uninitialized value '\\*p'" "" { target *-*-* } .-1 } */
110 free(p); /* { dg-warning "double-'free'" } */