summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2024-09-09 23:12:55 -0400
committerMatthew Sotoudeh <matthew@masot.net>2024-09-09 23:12:55 -0400
commit0c37353e44f0feaba9d3139f8b2afb33e75c7469 (patch)
tree3576cdeea71e3d1804dfc4ac0b215039fded492b /parse.c
parent5c3a9ab4f7dfcbcf109944277ed6ad04246c3e9e (diff)
properly handle passing type sizes with pointer arithmeticHEADmaster
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 0cbabc2..547d471 100644
--- a/parse.c
+++ b/parse.c
@@ -2380,7 +2380,9 @@ static Node *new_add(Node *lhs, Node *rhs, Token *tok) {
}
// ptr + num
- rhs = new_binary(ND_MUL, rhs, new_long(lhs->ty->base->size, tok), tok);
+ Node *base_size = new_long(lhs->ty->base->size, tok);
+ base_size->is_sizeof = lhs->ty->base;
+ rhs = new_binary(ND_MUL, rhs, base_size, tok);
return new_binary(ND_ADD, lhs, rhs, tok);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback