diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-10-31 13:54:24 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-10-31 13:54:24 +0100 |
| commit | 0e05d09b309bab493c41b6c788933cf82587afb8 (patch) | |
| tree | 1b68cde8c22b10b45c88c087566df2ba29e0f638 /src/prc1/td.c | |
| parent | cc1cbe64a5953004c80b0da3026748ee3061bca0 (diff) | |
| download | prc-0e05d09b309bab493c41b6c788933cf82587afb8.tar.gz | |
td.c: Use triplet for pointer type
Diffstat (limited to 'src/prc1/td.c')
| -rw-r--r-- | src/prc1/td.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/prc1/td.c b/src/prc1/td.c index a1212b4..2847146 100644 --- a/src/prc1/td.c +++ b/src/prc1/td.c @@ -7,6 +7,7 @@ #include "parse.h" #include "prv.h" #include "storage.h" +#include "triplet.h" #include "type.h" #include <errno.h> #include <limits.h> @@ -316,11 +317,15 @@ static int c(const struct lex *l, struct prv *p) static int p(const struct lex *l, struct prv *p) { + const char *tr = triplet(p); struct fn *fn = fn_cur(p), *pt = NULL; struct td *td = fn->td; struct type *nt = NULL; + const struct type *ptr; - if (!(pt = malloc(sizeof *pt))) + if (!tr || !(ptr = triplet_ptr(tr))) + goto failure; + else if (!(pt = malloc(sizeof *pt))) { perror("malloc(3)"); goto failure; @@ -338,9 +343,8 @@ static int p(const struct lex *l, struct prv *p) { .type = P, .tk = p->stk, - /* TODO: use frontend-specific pointer size */ - .sz = sizeof (void *), - .align = sizeof (void *), + .sz = ptr->sz, + .align = ptr->align, .u.p.fn = pt }; |
