diff options
| author | 2022-08-05 19:56:09 +0200 | |
|---|---|---|
| committer | 2022-08-05 19:56:09 +0200 | |
| commit | a2e4d0a565a8e756f36177003a51e224aca238b9 (patch) | |
| tree | 368f027a7e08cd7750f0b61f2e6277f70983fd37 /bootstrap/parse.c | |
| parent | c2a13e05596c724fbdbc3e8ff1266c099b675e56 (diff) | |
. operator on pointers
Diffstat (limited to 'bootstrap/parse.c')
| -rw-r--r-- | bootstrap/parse.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c index 32cd202..9c6f5a8 100644 --- a/bootstrap/parse.c +++ b/bootstrap/parse.c @@ -1000,9 +1000,12 @@ pexpostfix(struct parser *P) { }; } else if (lexmatch(P, &tok, '.')) { const char *fnam = (tok = lexexpect(P, TKident)).str; - if (ex.ty->t == TYstruct || ex.ty->t == TYunion) { - int idx = structfldnam2idx(ex.ty, fnam); - struct aggfield *fld = &ex.ty->agg.flds.d[idx]; + const struct type *ty = ex.ty; + if (ty->t == TYptr) + ty = ty->child; + if (ty->t == TYstruct || ty->t == TYunion) { + int idx = structfldnam2idx(ty, fnam); + struct aggfield *fld = &ty->agg.flds.d[idx]; if (idx < 0) fatal(P, tok.span, "%t has no such field `%s'", ex.ty, fnam); @@ -1012,7 +1015,7 @@ pexpostfix(struct parser *P) { ex.ty = fld->ty; ex.get.fld = fnam; } else { - fatal(P, tok.span, "cannot acces `%s': left-hand-side is not an aggregate (%t)", + fatal(P, tok.span, "cannot access `%s': left-hand-side is not an aggregate (%t)", fnam, ex.ty); } } else { |