From 6417c31a69ce06f35e00771fd2ecc87dbe48cd7a Mon Sep 17 00:00:00 2001 From: lemon Date: Tue, 24 Feb 2026 14:08:35 +0100 Subject: C23 true and false keywords --- c/c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'c/c.c') diff --git a/c/c.c b/c/c.c index d4e0aa6..019fb15 100644 --- a/c/c.c +++ b/c/c.c @@ -161,7 +161,7 @@ isexprtok(struct comp *cm) static const bool tks[] = { #define tk(x) [x] = 1 tk('+'), tk('-'), tk('*'), tk('&'), tk('~'), tk('!'), tk(TKINC), tk(TKDEC), - tk(TKWsizeof), tk(TKW_Alignof), tk(TKWalignof), + tk(TKWsizeof), tk(TKW_Alignof), tk(TKWalignof), tk(TKWtrue), tk(TKWfalse), tk('('), tk(TKNUMLIT), tk(TKCHRLIT), tk(TKSTRLIT), tk(TKW_Generic) #undef tk }; @@ -1080,6 +1080,9 @@ Unary: error(&tk.span, "bad %s literal %'tk", tk.t == TKNUMLIT ? "number" : "character", &tk); ex.ty.t = ty.t ? ty.t : TYINT; break; + case TKWtrue: case TKWfalse: + ex = mkexpr(ENUMLIT, tk.span, mktype(TYBOOL), .u = tk.t == TKWtrue); + break; case TKSTRLIT: ty = mktype(((const char []){TYCHAR, TYSHORT, TYINT})[tk.wide]); ex = mkexpr(ESTRLIT, tk.span, mkarrtype(ty, 0, tk.len+1), { .s.p = (void *)tk.s, .s.n = tk.len }); @@ -2312,8 +2315,7 @@ declspec(struct declstate *st, struct comp *cm, struct span *pspan) case TKWunsigned: arith |= KUNSIGNED; break; - case TKW_Bool: - case TKWbool: + case TKW_Bool: case TKWbool: if (arith & KBOOL) goto DupArith; arith |= KBOOL; break; -- cgit v1.2.3