summaryrefslogtreecommitdiff
path: root/usr.bin/pcc/ccom/pftn.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/pcc/ccom/pftn.c')
-rw-r--r--usr.bin/pcc/ccom/pftn.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/usr.bin/pcc/ccom/pftn.c b/usr.bin/pcc/ccom/pftn.c
index c8f4dd49e2e..9d2ddef2a2c 100644
--- a/usr.bin/pcc/ccom/pftn.c
+++ b/usr.bin/pcc/ccom/pftn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pftn.c,v 1.1 2007/10/07 17:58:51 otto Exp $ */
+/* $OpenBSD: pftn.c,v 1.2 2007/10/07 18:34:41 otto Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -69,6 +69,8 @@
#include <string.h> /* XXX - for strcmp */
+#include "cgram.h"
+
struct symtab *spname;
struct symtab *cftnsp;
static int strunem; /* currently parsed member type */
@@ -761,13 +763,13 @@ bstruct(char *name, int soru)
* Called after a struct is declared to restore the environment.
*/
NODE *
-dclstruct(struct rstack *r)
+dclstruct(struct rstack *r, int pa)
{
NODE *n;
struct params *l, *m;
struct suedef *sue;
struct symtab *p;
- int al, sa, sz;
+ int al, sa, sz, coff;
TWORD temp;
int i, high, low;
@@ -800,6 +802,10 @@ dclstruct(struct rstack *r)
i++;
sue->suelem = permalloc(sizeof(struct symtab *) * i);
+ coff = 0;
+ if (pa == PRAG_PACKED || pa == PRAG_ALIGNED)
+ strucoff = 0; /* must recount it */
+
for (i = 0; l != NULL; l = l->next) {
sue->suelem[i++] = p = l->sym;
@@ -814,11 +820,20 @@ dclstruct(struct rstack *r)
continue;
}
sa = talign(p->stype, p->ssue);
- if (p->sclass & FIELD) {
+ if (p->sclass & FIELD)
sz = p->sclass&FLDSIZ;
- } else {
+ else
sz = tsize(p->stype, p->sdf, p->ssue);
+
+ if (pa == PRAG_PACKED || pa == PRAG_ALIGNED) {
+ p->soffset = coff;
+ if (pa == PRAG_ALIGNED)
+ coff += ALLDOUBLE;
+ else
+ coff += sz;
+ strucoff = coff;
}
+
if (sz > strucoff)
strucoff = sz; /* for use with unions */
/*