aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/expand
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-12-05 03:30:37 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-12-10 23:26:15 +0100
commit3b9aa9647f5f4f0aac3dc4218128b94281a1264c (patch)
treed15dfe776a1714a9c84e2cde71ea9e064cf2f2b2 /validation/expand
parent9b2efc158c5c9700ffe355c59356879df7c9cc12 (diff)
downloadsparse-dev-3b9aa9647f5f4f0aac3dc4218128b94281a1264c.tar.gz
split testcases for type punning & constant initializer expansion
Several issues were covered by the same testcase. Fix this by splitting the testcases. Also, rename these testcases to a more descriptive name. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/expand')
-rw-r--r--validation/expand/constant-union-flt2int.c21
-rw-r--r--validation/expand/constant-union-int2flt.c20
-rw-r--r--validation/expand/constant-union-size.c21
3 files changed, 62 insertions, 0 deletions
diff --git a/validation/expand/constant-union-flt2int.c b/validation/expand/constant-union-flt2int.c
new file mode 100644
index 00000000..1c8f480b
--- /dev/null
+++ b/validation/expand/constant-union-flt2int.c
@@ -0,0 +1,21 @@
+union u {
+ int i;
+ float f;
+};
+
+static int foo(void)
+{
+ union u u = { .f = 0.123 };
+ return u.i;
+}
+
+/*
+ * check-name: constant-union-float-to-int
+ * check description: must not infer the int value from the float
+ * check-command: test-linearize -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): setfval\\.
+ * check-output-pattern(1): load\\.
+ */
diff --git a/validation/expand/constant-union-int2flt.c b/validation/expand/constant-union-int2flt.c
new file mode 100644
index 00000000..ff0a642a
--- /dev/null
+++ b/validation/expand/constant-union-int2flt.c
@@ -0,0 +1,20 @@
+union u {
+ int i;
+ float f;
+};
+
+static float foo(void)
+{
+ union u u = { .i = 3 };
+ return u.f;
+}
+
+/*
+ * check-name: constant-union-int-to-float
+ * check description: must not infer the float value from the int
+ * check-command: test-linearize -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(1): load\\.
+ */
diff --git a/validation/expand/constant-union-size.c b/validation/expand/constant-union-size.c
new file mode 100644
index 00000000..b6c3ac75
--- /dev/null
+++ b/validation/expand/constant-union-size.c
@@ -0,0 +1,21 @@
+union u {
+ char c;
+ float f;
+};
+
+static int foo(void)
+{
+ union u u = { .f = 0.123 };
+ return u.c;
+}
+
+/*
+ * check-name: constant-union-size
+ * check description: the size of the initializer doesn't match
+ * check-command: test-linearize -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: load\\.
+ * check-output-excludes: ret\\..*\\$
+ */