From 3e74de26d16780e626241e0c42313fcb37b91cf2 Mon Sep 17 00:00:00 2001 From: lemon Date: Sun, 21 Dec 2025 13:55:01 +0100 Subject: c: keyword aliases Some linux headers use __signed__ for whatever reason.. this is a general fix for those alternate keyword --- c/lex.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'c/lex.c') diff --git a/c/lex.c b/c/lex.c index 803cddb..9b6de51 100644 --- a/c/lex.c +++ b/c/lex.c @@ -1746,24 +1746,37 @@ findppcmd(const struct token *tk) static void identkeyword(struct token *tk) { +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-braces" +#endif static const struct { const char *s; struct kw { uchar t, cstd : 4, ext : 1; } kw; + const char *alias[2]; } kwtab[] = { -#define _(kw, cstd) { #kw, {TKW##kw, cstd} }, +#define _(kw, cstd, ...) { #kw, {TKW##kw, cstd}, __VA_ARGS__ }, #include "keywords.def" #undef _ }; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif static pmap_of(struct kw) kwmap; if (!kwmap.v) { pmap_init(&kwmap, 128); for (int i = 0; i < countof(kwtab); ++i) { + struct kw kw = kwtab[i].kw; /* allow future keywords but only if they begin with _ */ - if (kwtab[i].kw.cstd <= ccopt.cstd || kwtab[i].s[0] == '_') { - struct kw kw = kwtab[i].kw; - kw.ext = kwtab[i].kw.cstd > ccopt.cstd; + if (kw.cstd <= ccopt.cstd || kwtab[i].s[0] == '_') { + kw.ext = kw.cstd > ccopt.cstd; pmap_set(&kwmap, intern(kwtab[i].s), kw); } + for (const char *const *palias = kwtab[i].alias, *const *end = palias+2; + palias != end && *palias; ++palias) + { + pmap_set(&kwmap, intern(*palias), kw); + } } } struct kw *kw = pmap_get(&kwmap, tk->name); -- cgit v1.2.3