diff options
-rw-r--r-- | expr.c | 2 | ||||
-rw-r--r-- | tests/add-int-pointer.c | 4 | ||||
-rw-r--r-- | tests/add-int-pointer.qbe | 10 |
3 files changed, 15 insertions, 1 deletions
@@ -165,7 +165,7 @@ mkbinaryexpr(struct location *loc, enum tokenkind op, struct expression *l, stru break; } if (r->type->kind == TYPEPOINTER) - e = l, l = r, r = e; + e = l, l = r, r = e, rp = lp; if (l->type->kind != TYPEPOINTER || !(rp & PROPINT)) error(loc, "invalid operands to '+' operator"); t = l->type; diff --git a/tests/add-int-pointer.c b/tests/add-int-pointer.c new file mode 100644 index 0000000..be1a60f --- /dev/null +++ b/tests/add-int-pointer.c @@ -0,0 +1,4 @@ +int x[2]; +void f(void) { + 1 + x; +} diff --git a/tests/add-int-pointer.qbe b/tests/add-int-pointer.qbe new file mode 100644 index 0000000..22825ee --- /dev/null +++ b/tests/add-int-pointer.qbe @@ -0,0 +1,10 @@ +export +function $f() { +@start.1 +@body.2 + %.1 =l extsw 1 + %.2 =l mul %.1, 4 + %.3 =l add $x, %.2 + ret +} +export data $x = align 4 { z 8 } |