analyzer: add heuristics for switch on enum type [PR105273]
[platform/upstream/gcc.git] / gcc / testsuite / gcc.dg / analyzer / torture / switch-enum-pr105273-doom-p_floor.c
1 /* Reduced from linuxdoom-1.10's p_floor.c (GPLv2).  */
2
3 #define FRACBITS                16
4 #define FRACUNIT                (1<<FRACBITS)
5 #define PU_LEVSPEC              51
6 #define FLOORSPEED              FRACUNIT
7
8 typedef int fixed_t;
9 typedef struct line_s line_t;
10
11 typedef struct
12 {
13     fixed_t floorheight;
14     /* [...snip...] */
15 } sector_t;
16
17 typedef enum
18 {
19     build8,
20     turbo16
21
22 } stair_e;
23
24 typedef struct
25 {
26     /* [...snip...] */
27     fixed_t floordestheight;
28     fixed_t speed;
29 } floormove_t;
30
31 extern sector_t* sectors;
32
33 void* Z_Malloc (int size, int tag, void *ptr);
34
35 int
36 P_FindSectorFromLineTag
37 ( line_t* line,
38   int start );
39
40 int
41 EV_BuildStairs
42 ( line_t*       line,
43   stair_e       type )
44 {
45     int                 secnum;
46     int                 height;
47     /* [...snip...] */
48     int                 rtn;
49     
50     sector_t*           sec;
51     /* [...snip...] */
52
53     floormove_t*        floor;
54     
55     fixed_t             stairsize;
56     fixed_t             speed;
57
58     secnum = -1;
59     rtn = 0;
60     while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
61     {
62         sec = &sectors[secnum];
63
64         /* [...snip...] */
65
66         rtn = 1;
67         floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);
68         
69         /* [...snip...] */
70
71         switch(type)
72         {
73           case build8:
74             speed = FLOORSPEED/4;
75             stairsize = 8*FRACUNIT;
76             break;
77           case turbo16:
78             speed = FLOORSPEED*4;
79             stairsize = 16*FRACUNIT;
80             break;
81         }
82         floor->speed = speed; /* { dg-bogus "use of uninitialized value 'speed'" } */
83         height = sec->floorheight + stairsize; /* { dg-bogus "use of uninitialized value 'stairsize'" } */
84         floor->floordestheight = height;
85
86         /* [...snip...] */
87     }
88     return rtn;
89 }