diff options
-rw-r--r-- | expr.c | 2 | ||||
-rw-r--r-- | test/initializer-member-static.c | 2 | ||||
-rw-r--r-- | test/initializer-member-static.qbe | 1 |
3 files changed, 4 insertions, 1 deletions
@@ -958,7 +958,7 @@ postfixexpr(struct scope *s, struct expr *r) if (!m) error(&tok.loc, "struct/union has no member named '%s'", tok.lit); r = mkbinaryexpr(&tok.loc, TADD, exprconvert(r, &typeulong), mkconstexpr(&typeulong, offset)); - r = exprconvert(r, mkpointertype(m->type, tq | m->qual)); + r->type = mkpointertype(m->type, tq | m->qual); r = mkunaryexpr(TMUL, r); r->lvalue = lvalue; if (m->bits.before || m->bits.after) { diff --git a/test/initializer-member-static.c b/test/initializer-member-static.c new file mode 100644 index 0000000..7433a33 --- /dev/null +++ b/test/initializer-member-static.c @@ -0,0 +1,2 @@ +extern struct { int x; } s; +int *p = &s.x; diff --git a/test/initializer-member-static.qbe b/test/initializer-member-static.qbe new file mode 100644 index 0000000..c603c64 --- /dev/null +++ b/test/initializer-member-static.qbe @@ -0,0 +1 @@ +export data $p = align 8 { l $s + 0, } |