aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2021-12-06 13:58:50 -0800
committerMichael Forney <mforney@mforney.org>2021-12-06 13:59:11 -0800
commitaefb830ede6316f5fcf4c3c48b79a661c66c9f2e (patch)
tree0353766f49e74d60124d2d50ebf8216a8958bed1
parent673a92cead5dbc453a2234baffafb250cc1f41b6 (diff)
decl: Fix typedefs with type qualifiers
Previously, the qualifiers were saved, but accidentally ignored when the typedef was referenced.
-rw-r--r--decl.c1
-rw-r--r--test/typedef-qual.c3
-rw-r--r--test/typedef-qual.qbe1
3 files changed, 5 insertions, 0 deletions
diff --git a/decl.c b/decl.c
index 53aca7f..d81f54b 100644
--- a/decl.c
+++ b/decl.c
@@ -349,6 +349,7 @@ declspecs(struct scope *s, enum storageclass *sc, enum funcspec *fs, int *align)
if (!d || d->kind != DECLTYPE)
goto done;
t = d->type;
+ tq |= d->qual;
++ntypes;
next();
break;
diff --git a/test/typedef-qual.c b/test/typedef-qual.c
new file mode 100644
index 0000000..b027dab
--- /dev/null
+++ b/test/typedef-qual.c
@@ -0,0 +1,3 @@
+typedef const int T;
+const int x;
+T x;
diff --git a/test/typedef-qual.qbe b/test/typedef-qual.qbe
new file mode 100644
index 0000000..7cf0e40
--- /dev/null
+++ b/test/typedef-qual.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { z 4 }