aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-12-06 01:32:38 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-12-10 23:26:23 +0100
commitaa2235905e9afd2f14fbc26b0159e5b64e07314e (patch)
treeca5b69fc067b5ab1e11b02fe2683c7c41bbfb859
parent3b9aa9647f5f4f0aac3dc4218128b94281a1264c (diff)
downloadsparse-aa2235905e9afd2f14fbc26b0159e5b64e07314e.tar.gz
add testcase for expansion of default initializers
Currently, constant_symbol_value() is doing the expansion of a constant initializer when an explicit one is found but nothing is done for the default/implicit ones. Add a testcase to illustrate this. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--validation/expand/default-init-array.c16
-rw-r--r--validation/expand/default-init-struct.c23
2 files changed, 39 insertions, 0 deletions
diff --git a/validation/expand/default-init-array.c b/validation/expand/default-init-array.c
new file mode 100644
index 00000000..b372ea09
--- /dev/null
+++ b/validation/expand/default-init-array.c
@@ -0,0 +1,16 @@
+int test_array(int i)
+{
+ static const int a[3] = { [0] = 1, [2] = 3, };
+
+ return a[1];
+}
+
+/*
+ * check-name: default-init-array
+ * check-command: test-linearize -Wno-decl -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: phisrc\\..*return.*\\$0
+ * check-output-excludes: load\\.
+ */
diff --git a/validation/expand/default-init-struct.c b/validation/expand/default-init-struct.c
new file mode 100644
index 00000000..c843a1ab
--- /dev/null
+++ b/validation/expand/default-init-struct.c
@@ -0,0 +1,23 @@
+struct s {
+ int a;
+ int b;
+ int c;
+};
+
+
+int test_struct(void)
+{
+ struct s s = { .a = 1, .c = 3, };
+
+ return s.b;
+}
+
+/*
+ * check-name: default-init-struct
+ * check-command: test-linearize -Wno-decl -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: phisrc\\..*return.*\\$0
+ * check-output-excludes: load\\.
+ */