aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorBen Pfaff <blp@nicira.com>2011-05-04 16:39:54 -0700
committerChristopher Li <sparse@chrisli.org>2011-05-07 13:29:40 -0700
commitf20cbcc7ac20f6cd05f945ed1c09af8532094430 (patch)
treef29fc1178e7bcb2364c239279b58e4c398125e8a /validation
parent05e666547ee05acadf7fed2d1fc9967c27739e9a (diff)
downloadsparse-dev-f20cbcc7ac20f6cd05f945ed1c09af8532094430.tar.gz
evaluate: Allow sizeof(_Bool) to succeed.
Without this commit, sizeof(_Bool) provokes an error with "cannot size expression" because _Bool is a 1-bit type and thus not a multiple of a full byte in size. But sizeof(_Bool) is valid C that should evaluate to 1, so this commit fixes the problem and adds a regression test. Signed-off-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation')
-rw-r--r--validation/sizeof-bool.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/validation/sizeof-bool.c b/validation/sizeof-bool.c
new file mode 100644
index 00000000..6c68748a
--- /dev/null
+++ b/validation/sizeof-bool.c
@@ -0,0 +1,12 @@
+static int a(void)
+{
+ return sizeof(_Bool);
+}
+/*
+ * check-name: sizeof(_Bool) is valid
+ * check-description: sizeof(_Bool) was rejected because _Bool is not an even
+ * number of bytes
+ * check-error-start
+sizeof-bool.c:3:16: warning: expression using sizeof bool
+ * check-error-end
+ */