Debian Codegraph @

gcc/testsuite/gcc.dg/analyzer/explode-1.c

raw
1 /* { dg-additional-options "-Wno-analyzer-too-complex" } */
2
3 #include <stdlib.h>
4
5 extern int get (void);
6
7 /* In theory each of p0...p8 can be in various malloc states,
8 independently, so the total combined number of states
9 at any program point within the loop is NUM_VARS * NUM_STATES. */
10
11 void test (void)
12 {
13 void *p0, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8;
14 void **pp;
15 while (get ())
16 {
17 switch (get ())
18 {
19 default:
20 case 0:
21 pp = &p0;
22 break;
23 case 1:
24 pp = &p1;
25 break;
26 case 2:
27 pp = &p2;
28 break;
29 case 3:
30 pp = &p3;
31 break;
32 case 4:
33 pp = &p4;
34 break;
35 case 5:
36 pp = &p5;
37 break;
38 case 6:
39 pp = &p6;
40 break;
41 case 7:
42 pp = &p7;
43 break;
44 }
45
46 switch (get ())
47 {
48 default:
49 case 0:
50 *pp = malloc (16); /* { dg-warning "leak" "" { xfail *-*-* } } */
51 // TODO: xfail
52 break;
53 case 1:
54 free (*pp);
55 break;
56 case 2:
57 /* no-op. */
58 break;
59 }
60 }
61 }