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