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