diff options
| author | 2022-08-12 16:43:06 +0200 | |
|---|---|---|
| committer | 2022-08-12 16:43:06 +0200 | |
| commit | 1eb17cda6780476b166b55d0fedc3ad355969e87 (patch) | |
| tree | ccb4ffa74cc37f24e93d4325ccf395d3fe73529f /bootstrap/parse.c | |
| parent | f14aee6184568bae34f8d8d8f9140fa760099fa5 (diff) | |
selfhosted lexer
Diffstat (limited to 'bootstrap/parse.c')
| -rw-r--r-- | bootstrap/parse.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c index 7c31ce1..7ff52bf 100644 --- a/bootstrap/parse.c +++ b/bootstrap/parse.c @@ -1178,7 +1178,7 @@ pexprimary(struct parser *P) { ex = parsearrini(P, P->targty); } else if (lexmatch(P, &tok, TKkw_sizeof)) { ex.t = Eintlit; - ex.ty = ty_usize; + ex.ty = ty_isize; if (lexmatch(P, &tok, '(')) { struct expr exp = parseexpr(P); ex.i = exp.ty->size; @@ -1320,13 +1320,13 @@ pexpostfix(struct parser *P) { if (ty->t == TYarr) { assert(ty->length >= 0); ex.t = Eintlit; - ex.ty = ty->konst ? constify(ty_usize) : ty_usize; + ex.ty = ty->konst ? constify(ty_isize) : ty_isize; ex.span = tok.span; ex.i = ty->length; } else if (ty->t == TYslice) { ex.child = exprdup(ex); ex.t = Elen; - ex.ty = ty->konst ? constify(ty_usize) : ty_usize; + ex.ty = ty->konst ? constify(ty_isize) : ty_isize; ex.span = tok.span; } else { fatal(P, ex.span, "invalid operand to `.#len' (%t)", ex.ty); @@ -1654,6 +1654,7 @@ pexcmp(struct parser *P) { ex = pexbitarith(P); if (P->used_targty) return ex; if (matchcmpop(P, &tok)) { + P->targty = ex.ty; struct expr rhs = pexbitarith(P); if (!typeof2(ex.ty, rhs.ty)) fatal(P, tok.span, "incompatible operands %t and %t to binary operator %T", @@ -1713,7 +1714,7 @@ pexcond(struct parser *P) { struct expr ex3; const struct type *ty; - if (ex.ty->t != TYbool) + if (ex.ty->t != TYbool && ex.ty->t != TYptr) fatal(P, ex.span, "invalid test operand %t to conditional operator", ex.ty); lexexpect(P, ':'); |