Debian Codegraph @

gcc/testsuite/gcc.dg/analyzer/torture/switch-enum-pr105273-doom-p_maputl.c

raw
1 /* Reduced from linuxdoom-1.10's p_maputl.c (GPLv2). */
2
3 typedef int fixed_t;
4
5 enum
6 {
7 BOXTOP,
8 BOXBOTTOM,
9 BOXLEFT,
10 BOXRIGHT
11 };
12
13 typedef struct
14 {
15 fixed_t x;
16 fixed_t y;
17 } vertex_t;
18
19 typedef enum
20 {
21 ST_HORIZONTAL,
22 ST_VERTICAL,
23 ST_POSITIVE,
24 ST_NEGATIVE
25 } slopetype_t;
26
27 typedef struct line_s
28 {
29 vertex_t* v1;
30 /* [...snip...] */
31
32 fixed_t dx;
33 fixed_t dy;
34
35 /* [...snip...] */
36 slopetype_t slopetype;
37 /* [...snip...] */
38 } line_t;
39
40 int P_PointOnLineSide (fixed_t x, fixed_t y, line_t* line);
41
42 int
43 P_BoxOnLineSide
44 ( fixed_t* tmbox,
45 line_t* ld )
46 {
47 int p1;
48 int p2;
49
50 switch (ld->slopetype)
51 {
52 case ST_HORIZONTAL:
53 p1 = tmbox[BOXTOP] > ld->v1->y;
54 p2 = tmbox[BOXBOTTOM] > ld->v1->y;
55 if (ld->dx < 0)
56 {
57 p1 ^= 1;
58 p2 ^= 1;
59 }
60 break;
61
62 case ST_VERTICAL:
63 p1 = tmbox[BOXRIGHT] < ld->v1->x;
64 p2 = tmbox[BOXLEFT] < ld->v1->x;
65 if (ld->dy < 0)
66 {
67 p1 ^= 1;
68 p2 ^= 1;
69 }
70 break;
71
72 case ST_POSITIVE:
73 p1 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXTOP], ld);
74 p2 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXBOTTOM], ld);
75 break;
76
77 case ST_NEGATIVE:
78 p1 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXTOP], ld);
79 p2 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXBOTTOM], ld);
80 break;
81 }
82
83 if (p1 == p2) /* { dg-bogus "use of uninitialized value" } */
84 return p1; /* { dg-bogus "use of uninitialized value" } */
85 return -1;
86 }