summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2023-07-30 18:18:25 -0700
committerMatthew Sotoudeh <matthew@masot.net>2023-07-30 18:18:25 -0700
commit44662c62f444fc50fe523d987199f6a10c9a693c (patch)
treeb52a68243ef283471c53d224fd3f0ae87f8c0d0f /parse.c
parentf2297c20b69d942fd1e8fdcdd8f4d142c71de662 (diff)
add support for passing through sizeof & alignofs
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/parse.c b/parse.c
index fe17515..0cbabc2 100644
--- a/parse.c
+++ b/parse.c
@@ -3020,7 +3020,9 @@ static Node *primary(Token **rest, Token *tok) {
return new_binary(ND_COMMA, lhs, rhs, tok);
}
- return new_ulong(ty->size, start);
+ Node *res = new_ulong(ty->size, start);
+ res->is_sizeof = ty;
+ return res;
}
if (equal(tok, "sizeof")) {
@@ -3028,19 +3030,25 @@ static Node *primary(Token **rest, Token *tok) {
add_type(node);
if (node->ty->kind == TY_VLA)
return new_var_node(node->ty->vla_size, tok);
- return new_ulong(node->ty->size, tok);
+ Node *res = new_ulong(node->ty->size, tok);
+ res->is_sizeof = node->ty;
+ return res;
}
if (equal(tok, "_Alignof") && equal(tok->next, "(") && is_typename(tok->next->next)) {
Type *ty = typename(&tok, tok->next->next);
*rest = skip(tok, ")");
- return new_ulong(ty->align, tok);
+ Node *res = new_ulong(ty->align, tok);
+ res->is_alignof = ty;
+ return res;
}
if (equal(tok, "_Alignof")) {
Node *node = unary(rest, tok->next);
add_type(node);
- return new_ulong(node->ty->align, tok);
+ Node *res = new_ulong(node->ty->align, tok);
+ res->is_alignof = node->ty;
+ return res;
}
if (equal(tok, "_Generic"))
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback