aboutsummaryrefslogtreecommitdiff
path: root/src/prc1
diff options
context:
space:
mode:
Diffstat (limited to 'src/prc1')
-rw-r--r--src/prc1/td.c12
-rw-r--r--src/prc1/type.c12
2 files changed, 16 insertions, 8 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
};
diff --git a/src/prc1/type.c b/src/prc1/type.c
index fbb332b..2b10da0 100644
--- a/src/prc1/type.c
+++ b/src/prc1/type.c
@@ -307,9 +307,13 @@ static int anum(const struct lex *l, struct prv *p)
static int p(const struct lex *l, struct prv *p)
{
- struct type *t = malloc(sizeof *t), *tt;
+ const char *tr = triplet(p);
+ const struct type *ptr;
+ struct type *t, *tt;
- if (!t)
+ if (!tr || !(ptr = triplet_ptr(tr)))
+ return -1;
+ else if (!(t = malloc(sizeof *t)))
{
perror("malloc(3)");
return -1;
@@ -319,8 +323,8 @@ static int p(const struct lex *l, struct prv *p)
{
.type = PTR,
/* TODO: ask target for sizeof (void *) */
- .sz = sizeof (void *),
- .align = sizeof (void *)
+ .sz = ptr->sz,
+ .align = ptr->align
};
if ((tt = p->t) && tt->type == ARY)