aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-02-13 15:42:43 -0800
committerMichael Forney <mforney@mforney.org>2019-02-13 19:42:25 -0800
commit792beff25a6ca5aaf26d5a6dd2449f2e0aefbebb (patch)
treec4e970dd98937f1c1caefeabce62e4867064d186
parent8040e25abcad4b106514315a53f4723e3a387959 (diff)
Ignore qualifiers when parsing initializers
-rw-r--r--init.c2
-rw-r--r--tests/const-init.c1
-rw-r--r--tests/const-init.qbe1
3 files changed, 3 insertions, 1 deletions
diff --git a/init.c b/init.c
index 7068065..bb8ad82 100644
--- a/init.c
+++ b/init.c
@@ -211,7 +211,7 @@ parseinit(struct scope *s, struct type *t)
p.cur = NULL;
p.sub = p.obj;
p.sub->offset = 0;
- p.sub->type = t;
+ p.sub->type = typeunqual(t, NULL);
for (;;) {
if (p.cur) {
if (tok.kind == TLBRACK || tok.kind == TPERIOD)
diff --git a/tests/const-init.c b/tests/const-init.c
new file mode 100644
index 0000000..4d33888
--- /dev/null
+++ b/tests/const-init.c
@@ -0,0 +1 @@
+const struct {struct {int x, y;} t;} s = {{{1}, 2}};
diff --git a/tests/const-init.qbe b/tests/const-init.qbe
new file mode 100644
index 0000000..fb5d305
--- /dev/null
+++ b/tests/const-init.qbe
@@ -0,0 +1 @@
+export data $s = align 4 { w 1, w 2, }