From c3a8355845206f14df8836202b8ea301b8ad829a Mon Sep 17 00:00:00 2001 From: Teddy Date: Fri, 18 Apr 2014 15:57:03 +0800 Subject: ... --- semantics.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3-70-g09d2