ignore VOID when trying to if-convert phi-nodes
[smatch.git] / validation / conditional-type.c
bloba14c05ec1d953dd8be8b287bca3f6a56ff45e8be
1 extern void afun(void);
2 extern void vcond(void);
3 static int array[3];
5 struct state {
6 int nr:2;
7 };
9 enum number {
10 zero,
11 one,
12 two,
13 many,
16 static int bad_if(struct state s)
18 if (vcond()) return 1;
19 if (s) return 1;
20 return 0;
22 static void bad_if2(int *a, int *b)
24 if (vcond()) *a = 1;
25 *b = 0;
27 static int bad_sel(struct state s)
29 return vcond() ? 1 : 0;
30 return s ? 1 : 0;
32 static int bad_loop_void(void)
34 while (vcond())
36 for (;vcond();)
40 while (vcond());
41 return 0;
45 static int good_if_int(int a, _Bool b, long c, unsigned char d)
47 if (a) return 1;
48 if (b) return 1;
49 if (c) return 1;
50 if (d) return 1;
51 return 0;
53 static int good_if_float(float a, double b)
55 if (a) return 1;
56 if (b) return 1;
57 return 0;
59 static int good_if_enum(void)
61 if (many) return 1;
62 return 0;
64 static int good_if_bitfield(struct state s, struct state *p)
66 if (s.nr) return 1;
67 if (p->nr) return 1;
68 return 0;
70 static int good_if_ptr(void *ptr)
72 if (ptr) return 1;
73 if (array) return 1;
74 if (afun) return 1;
75 return 0;
79 * check-name: conditional-type
81 * check-error-start
82 conditional-type.c:18:18: error: incorrect type in conditional
83 conditional-type.c:18:18: got void
84 conditional-type.c:19:13: error: incorrect type in conditional
85 conditional-type.c:19:13: got struct state s
86 conditional-type.c:24:18: error: incorrect type in conditional
87 conditional-type.c:24:18: got void
88 conditional-type.c:29:21: error: incorrect type in conditional
89 conditional-type.c:29:21: got void
90 conditional-type.c:30:16: error: incorrect type in conditional
91 conditional-type.c:30:16: got struct state s
92 conditional-type.c:34:21: error: incorrect type in conditional
93 conditional-type.c:34:21: got void
94 conditional-type.c:36:20: error: incorrect type in conditional
95 conditional-type.c:36:20: got void
96 conditional-type.c:40:21: error: incorrect type in conditional
97 conditional-type.c:40:21: got void
98 * check-error-end