aboutsummaryrefslogtreecommitdiffhomepage
path: root/c/lex.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-21 13:55:01 +0100
committerlemon <lsof@mailbox.org>2025-12-21 16:44:43 +0100
commit3e74de26d16780e626241e0c42313fcb37b91cf2 (patch)
tree76092ff61192c0f8e36d7bd50c58fc7b57b7999b /c/lex.c
parent201f015408a160583b6644c0c3ea07b3139c8d91 (diff)
c: keyword aliases
Some linux headers use __signed__ for whatever reason.. this is a general fix for those alternate keyword
Diffstat (limited to 'c/lex.c')
-rw-r--r--c/lex.c21
1 files changed, 17 insertions, 4 deletions
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);