• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 typedef unsigned   int __attribute__((bitwise)) large_t;
2 #define	LBIT	((__attribute__((force)) large_t) 1)
3 
lfoo(large_t x)4 _Bool lfoo(large_t x) { return x; }
qfoo(large_t x)5 _Bool qfoo(large_t x) { _Bool r = x; return r; }
xfoo(large_t x)6 _Bool xfoo(large_t x) { return (_Bool)x; }
lbar(large_t x)7 _Bool lbar(large_t x) { return ~x; }
qbar(large_t x)8 _Bool qbar(large_t x) { _Bool r = ~x; return r; }
xbar(large_t x)9 _Bool xbar(large_t x) { return (_Bool)~x; }
lbaz(large_t x)10 _Bool lbaz(large_t x) { return !x; }
qbaz(large_t x)11 _Bool qbaz(large_t x) { _Bool r = !x; return r; }
xbaz(large_t x)12 _Bool xbaz(large_t x) { return (_Bool)!x; }
lqux(large_t x)13 _Bool lqux(large_t x) { return x & LBIT; }
qqux(large_t x)14 _Bool qqux(large_t x) { _Bool r = x & LBIT; return r; }
xqux(large_t x)15 _Bool xqux(large_t x) { return (_Bool)(x & LBIT); }
16 
17 
18 typedef unsigned short __attribute__((bitwise)) small_t;
19 #define	SBIT	((__attribute__((force)) small_t) 1)
20 
sfoo(small_t x)21 _Bool sfoo(small_t x) { return x; }
tfoo(small_t x)22 _Bool tfoo(small_t x) { _Bool r = x; return r; }
zfoo(small_t x)23 _Bool zfoo(small_t x) { return (_Bool)x; }
sbar(small_t x)24 _Bool sbar(small_t x) { return ~x; }
tbar(small_t x)25 _Bool tbar(small_t x) { _Bool r = ~x; return r; }
zbar(small_t x)26 _Bool zbar(small_t x) { return (_Bool)~x; }
sbaz(small_t x)27 _Bool sbaz(small_t x) { return !x; }
tbaz(small_t x)28 _Bool tbaz(small_t x) { _Bool r = !x; return r; }
zbaz(small_t x)29 _Bool zbaz(small_t x) { return (_Bool)!x; }
squx(small_t x)30 _Bool squx(small_t x) { return x & SBIT; }
tqux(small_t x)31 _Bool tqux(small_t x) { _Bool r = x & SBIT; return r; }
zqux(small_t x)32 _Bool zqux(small_t x) { return (_Bool)(x & SBIT); }
33 
34 /*
35  * check-name: bool-cast-restricted.c
36  * check-command: sparse -Wno-decl $file
37  *
38  * check-error-start
39 bool-cast-restricted.c:24:32: warning: restricted small_t degrades to integer
40 bool-cast-restricted.c:25:35: warning: restricted small_t degrades to integer
41 bool-cast-restricted.c:26:33: warning: restricted small_t degrades to integer
42  * check-error-end
43  */
44