aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-05-11 14:23:11 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-05-19 06:50:45 +0200
commit28ba15f4e8ce477726e80b1e22677fe144973b49 (patch)
treee502955a49a05e049fb9504aae6d634aa12e053b /validation
parenta6aaa59cec44972513f1544eb4c2d389eadf14a6 (diff)
downloadsparse-dev-28ba15f4e8ce477726e80b1e22677fe144973b49.tar.gz
more tests for implicit 'bool <- restricted' casts
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/bool-cast-restricted.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/validation/bool-cast-restricted.c b/validation/bool-cast-restricted.c
index f6776b05..0aa9f35b 100644
--- a/validation/bool-cast-restricted.c
+++ b/validation/bool-cast-restricted.c
@@ -2,24 +2,33 @@ typedef unsigned int __attribute__((bitwise)) large_t;
#define LBIT ((__attribute__((force)) large_t) 1)
_Bool lfoo(large_t x) { return x; }
+_Bool qfoo(large_t x) { _Bool r = x; return r; }
_Bool lbar(large_t x) { return ~x; }
+_Bool qbar(large_t x) { _Bool r = ~x; return r; }
_Bool lbaz(large_t x) { return !x; }
+_Bool qbaz(large_t x) { _Bool r = !x; return r; }
_Bool lqux(large_t x) { return x & LBIT; }
+_Bool qqux(large_t x) { _Bool r = x & LBIT; return r; }
typedef unsigned short __attribute__((bitwise)) small_t;
#define SBIT ((__attribute__((force)) small_t) 1)
_Bool sfoo(small_t x) { return x; }
+_Bool tfoo(small_t x) { _Bool r = x; return r; }
_Bool sbar(small_t x) { return ~x; }
+_Bool tbar(small_t x) { _Bool r = ~x; return r; }
_Bool sbaz(small_t x) { return !x; }
+_Bool tbaz(small_t x) { _Bool r = !x; return r; }
_Bool squx(small_t x) { return x & SBIT; }
+_Bool tqux(small_t x) { _Bool r = x & SBIT; return r; }
/*
* check-name: bool-cast-restricted.c
* check-command: sparse -Wno-decl $file
*
* check-error-start
-bool-cast-restricted.c:14:32: warning: restricted small_t degrades to integer
+bool-cast-restricted.c:19:32: warning: restricted small_t degrades to integer
+bool-cast-restricted.c:20:35: warning: restricted small_t degrades to integer
* check-error-end
*/