new file mode 100644
@@ -0,0 +1,15 @@
+int foo(void)
+{
+ int a[2][3] = {{0, 1, 2},{3, 4, 5}};
+ return a[1][2];
+}
+
+/*
+ * check-name: constant-init-nested-array
+ * check-command: test-linearize -Wno-decl -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: phisrc\\..*\\$5
+ * check-output-excludes: load\\.
+ */
new file mode 100644
@@ -0,0 +1,23 @@
+struct s {
+ int a;
+ struct {
+ int b;
+ int c;
+ } s;
+};
+
+int foo(void)
+{
+ struct s s = {1, {2, 3}};
+ return s.s.c;
+}
+
+/*
+ * check-name: constant-init-nested-struct
+ * check-command: test-linearize -Wno-decl -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: phisrc\\..*\\$3
+ * check-output-excludes: load\\.
+ */
new file mode 100644
@@ -0,0 +1,15 @@
+char foo(void)
+{
+ static const char s[] = "abc?";
+ return s[3];
+}
+
+/*
+ * check-name: constant-init-nested-array
+ * check-command: test-linearize -Wno-decl -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: phisrc\\..*\\$63
+ * check-output-pattern(0,1): load\\.
+ */
Constant expansion of symbols with a complex type is not done like for simpler ones. Only the first-level EXPR_INITIALIZER is handled. Add some testcases for this. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- .../expand/constant-init-nested-array.c | 15 ++++++++++++ .../expand/constant-init-nested-struct.c | 23 +++++++++++++++++++ validation/expand/constant-init-string.c | 15 ++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 validation/expand/constant-init-nested-array.c create mode 100644 validation/expand/constant-init-nested-struct.c create mode 100644 validation/expand/constant-init-string.c