1 extern void afun(void);
2 extern void vcond(void);
3 static int array[3];
4 
5 struct state {
6 	int nr:2;
7 };
8 
9 enum number {
10 	zero,
11 	one,
12 	two,
13 	many,
14 };
15 
bad_if(struct state s)16 static int bad_if(struct state s)
17 {
18 	if (vcond()) return 1;
19 	if (s) return 1;
20 	return 0;
21 }
bad_if2(int * a,int * b)22 static void bad_if2(int *a, int *b)
23 {
24 	if (vcond()) *a = 1;
25 	*b = 0;
26 }
bad_sel(struct state s)27 static int bad_sel(struct state s)
28 {
29 	return vcond() ? 1 : 0;
30 	return s ? 1 : 0;
31 }
bad_loop_void(void)32 static int bad_loop_void(void)
33 {
34 	while (vcond())
35 		;
36 	for (;vcond();)
37 		;
38 	do
39 		;
40 	while (vcond());
41 	return 0;
42 }
43 
44 
good_if_int(int a,_Bool b,long c,unsigned char d)45 static int good_if_int(int a, _Bool b, long c, unsigned char d)
46 {
47 	if (a) return 1;
48 	if (b) return 1;
49 	if (c) return 1;
50 	if (d) return 1;
51 	return 0;
52 }
good_if_float(float a,double b)53 static int good_if_float(float a, double b)
54 {
55 	if (a) return 1;
56 	if (b) return 1;
57 	return 0;
58 }
good_if_enum(void)59 static int good_if_enum(void)
60 {
61 	if (many) return 1;
62 	return 0;
63 }
good_if_bitfield(struct state s,struct state * p)64 static int good_if_bitfield(struct state s, struct state *p)
65 {
66 	if (s.nr) return 1;
67 	if (p->nr) return 1;
68 	return 0;
69 }
good_if_ptr(void * ptr)70 static int good_if_ptr(void *ptr)
71 {
72 	if (ptr) return 1;
73 	if (array) return 1;
74 	if (afun) return 1;
75 	return 0;
76 }
77 
78 /*
79  * check-name: conditional-type
80  *
81  * check-error-start
82 conditional-type.c:18:18: error: incorrect type in conditional (non-scalar type)
83 conditional-type.c:18:18:    got void
84 conditional-type.c:19:13: error: incorrect type in conditional (non-scalar type)
85 conditional-type.c:19:13:    got struct state s
86 conditional-type.c:24:18: error: incorrect type in conditional (non-scalar type)
87 conditional-type.c:24:18:    got void
88 conditional-type.c:29:21: error: incorrect type in conditional (non-scalar type)
89 conditional-type.c:29:21:    got void
90 conditional-type.c:30:16: error: incorrect type in conditional (non-scalar type)
91 conditional-type.c:30:16:    got struct state s
92 conditional-type.c:34:21: error: incorrect type in conditional (non-scalar type)
93 conditional-type.c:34:21:    got void
94 conditional-type.c:36:20: error: incorrect type in conditional (non-scalar type)
95 conditional-type.c:36:20:    got void
96 conditional-type.c:40:21: error: incorrect type in conditional (non-scalar type)
97 conditional-type.c:40:21:    got void
98  * check-error-end
99  */
100