aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2024-03-22 00:58:50 -0700
committerMichael Forney <mforney@mforney.org>2024-03-22 00:58:50 -0700
commite56d50bb88c984af8e1c45fa51aec3ee1f9f505d (patch)
tree2f00fe08bf2d6f6ed86e006ee34b81f55511efe9
parentc05ee6ff4daed6a899f98feeaa05ef166aa3adc3 (diff)
decl: Implement typeof_unqual
-rw-r--r--decl.c14
-rw-r--r--test/typeof_unqual.c3
-rw-r--r--test/typeof_unqual.qbe2
3 files changed, 19 insertions, 0 deletions
diff --git a/decl.c b/decl.c
index 3a84a02..fc48dc9 100644
--- a/decl.c
+++ b/decl.c
@@ -420,6 +420,20 @@ declspecs(struct scope *s, enum storageclass *sc, enum funcspec *fs, int *align)
++ntypes;
expect(TRPAREN, "to close 'typeof'");
break;
+ case TTYPEOF_UNQUAL:
+ next();
+ expect(TLPAREN, "after 'typeof_unqual'");
+ t = typename(s, NULL);
+ if (!t) {
+ e = expr(s);
+ if (e->decayed)
+ e = e->base;
+ t = e->type;
+ delexpr(e);
+ }
+ ++ntypes;
+ expect(TRPAREN, "to close 'typeof_unqual'");
+ break;
/* 6.7.5 Alignment specifier */
case TALIGNAS:
diff --git a/test/typeof_unqual.c b/test/typeof_unqual.c
new file mode 100644
index 0000000..1c748df
--- /dev/null
+++ b/test/typeof_unqual.c
@@ -0,0 +1,3 @@
+const int a;
+int b;
+typeof_unqual(a) b;
diff --git a/test/typeof_unqual.qbe b/test/typeof_unqual.qbe
new file mode 100644
index 0000000..1305c74
--- /dev/null
+++ b/test/typeof_unqual.qbe
@@ -0,0 +1,2 @@
+export data $a = align 4 { z 4 }
+export data $b = align 4 { z 4 }