aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <[email protected]>2014-04-18 15:57:03 +0800
committerTeddy <[email protected]>2014-04-18 15:57:03 +0800
commitc3a8355845206f14df8836202b8ea301b8ad829a (patch)
tree06fab7306fa3f80e1c50549e1041006b03cf3ad0
parent1460ad1da5f294ea77e2e737b5523627b12104c3 (diff)
...
-rw-r--r--semantics.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/semantics.c b/semantics.c
index 106c14d..1671a3f 100644
--- a/semantics.c
+++ b/semantics.c
@@ -295,7 +295,10 @@ int calc_size(CType_t type) {
CVar_t p = type->rec.st.flist;
if (!p) return -1;
for (; p; p = p->next)
+ {
size += align_shift(calc_size(p->type));
+ p->start = size;
+ }
}
break;
case CUNION:
@@ -307,6 +310,7 @@ int calc_size(CType_t type) {
{
int t = align_shift(calc_size(p->type));
if (t > size) size = t;
+ p->start = 0;
}
}
break;
@@ -1117,7 +1121,8 @@ ExpType exp_check_postfix(CNode *p, CScope_t scope) {
post->chd->rec.strval);
if (!fv)
ERROR((p, "struct/union has no member named '%s'", post->chd->rec.strval));
- p->ext.var = fv;
+ p->ext.var = NULL;
+ p->ext.offest = fv->start;
op1.type = fv->type;
op1.lval = 1;
}