aboutsummaryrefslogtreecommitdiffhomepage
path: root/c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-02-24 14:08:35 +0100
committerlemon <lsof@mailbox.org>2026-02-24 14:08:35 +0100
commit6417c31a69ce06f35e00771fd2ecc87dbe48cd7a (patch)
tree00f0111400eb9612ccb0c573146a193549d07509 /c
parent4dc998cca9a374325208d66b0700dddcb20840f0 (diff)
C23 true and false keywords
Diffstat (limited to 'c')
-rw-r--r--c/c.c8
1 files changed, 5 insertions, 3 deletions
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;