blob: 037de233432b226287396df7c98004dfdf948ecd (
plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/* $OpenBSD: test-24.c,v 1.1 2010/07/25 23:00:05 guenther Exp $ */
/*
* Placed in the public domain by Philip Guenther <guenther@openbsd.org>.
*
* Test _Bool handling.
* Based in part on test-19.c, by Chad Loder <cloder@openbsd.org>.
*/
void
f(void)
{
_Bool b1;
const _Bool b2 = 1;
_Bool const b3 = 0;
float fl = 4.3f;
_Bool *bp = &b1;
*bp = 3;
if (b1 > 1 ||
b2 < 0 ||
*bp > 1 ||
*bp < 0)
{
*bp = 0;
}
b1 = fl;
}
void b1 (_Bool b){ b++; }
void c1 (signed char c){ c++; }
void uc1 (unsigned char uc) { uc++; }
void s1 (short s) { s++; }
void us1 (unsigned short us) { us++; }
void i1 (int i) { i++; }
void ui1 (unsigned int ui) { ui++; }
void f1 (float f) { f++; }
void l1 (long l) { l++; }
void ul1 (unsigned long ul) { ul++; }
void d1 (double d) { d++; }
void ll1 (long long ll) { ll++; }
void ull1 (unsigned long long ull) { ull++; }
void ld1 (long double ld) { ld++; }
/* ARGSUSED */
int
main(int argc, char* argv[])
{
_Bool B = 1;
signed char C = 1;
unsigned char UC = 1;
short S = 1;
unsigned short US = 1;
int I = 1;
unsigned int UI = 1;
long L = 1;
unsigned long UL = 1;
long long LL = 1;
unsigned long long ULL = 1;
float F = 1.0f;
double D = 1.0;
long double LD = 1.0L;
f();
/* test with variables */
b1(B);
b1(C);
b1(UC);
b1(S);
b1(US);
b1(I);
b1(UI);
b1(L);
b1(UL);
b1(LL);
b1(ULL);
b1(F);
b1(D);
b1(LD);
c1(B);
uc1(B);
s1(B);
us1(B);
i1(B);
ui1(B);
f1(B);
l1(B);
ul1(B);
d1(B);
ll1(B);
ull1(B);
ld1(B);
/* now test with int constants */
b1(-1);
b1(0);
b1(1);
/* now test with long constants */
b1(-1L);
b1(0L);
b1(1L);
/* now test with float constants */
b1(-1.0f);
b1(0.0f);
b1(1.0f);
/* now test with double constants */
b1(-1.0);
b1(0.0);
b1(1.0);
/* now test with long double constants */
b1(-1.0L);
b1(0.0L);
b1(1.0L);
return 0;
}
|