aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-20 00:24:59 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-11-17 10:04:36 +0100
commit8fd641539ce445336704001ed47673882ce7968b (patch)
tree97255e8f6323fb1fbd8103b8e8d2710c3dc458b7 /validation
parent674b8c241569472b9da50e87177fe0bd2ced4b71 (diff)
downloadsparse-dev-8fd641539ce445336704001ed47673882ce7968b.tar.gz
add support for wider type in switch-case
Currently the different cases of a switch-statement, or more exactly the 'struct multijmp' that hold the value of these cases excepted only value of 'int' type. Trying to use a wider value results in the value being truncated but any integer value should be valid. Fix this by unsigned 'long long' to hold these values. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/switch-long.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/validation/switch-long.c b/validation/switch-long.c
new file mode 100644
index 00000000..5bfdb439
--- /dev/null
+++ b/validation/switch-long.c
@@ -0,0 +1,47 @@
+void def(void);
+void r0(void);
+void r1(void);
+
+void sw_long(long long a)
+{
+ switch (a) {
+ case 0: return r0();
+ case 1LL << 00: return r1();
+ case 1LL << 32: return r1();
+ }
+
+ return def();
+}
+
+/*
+ * check-name: switch-long
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-start
+sw_long:
+.L0:
+ <entry-point>
+ switch.64 %arg1, 0 -> .L2, 1 -> .L3, 4294967296 -> .L4, default -> .L1
+
+.L2:
+ call r0
+ br .L5
+
+.L3:
+ call r1
+ br .L5
+
+.L4:
+ call r1
+ br .L5
+
+.L1:
+ call def
+ br .L5
+
+.L5:
+ ret
+
+
+ * check-output-end
+ */