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