aboutsummaryrefslogtreecommitdiffhomepage
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/c.c11
-rw-r--r--c/lex.c4
-rw-r--r--c/lex.h1
3 files changed, 12 insertions, 4 deletions
diff --git a/c/c.c b/c/c.c
index ab477da..02dbdcb 100644
--- a/c/c.c
+++ b/c/c.c
@@ -9,8 +9,8 @@
static int
lexc(struct comp *cm, struct token *tk)
{
- struct token tk2;
- int t = lex(cm->lx, tk);
+ struct token tk2, tk_[1];
+ int t = lex(cm->lx, tk ? tk : tk_);
if (t == TKSTRLIT && peek(cm, &tk2) == TKSTRLIT && tk2.wide == tk->wide) {
/* 5.1.1.2 Translation phase 6: concatenate adjacent string literal tokens */
static char buf[200];
@@ -44,6 +44,13 @@ lexc(struct comp *cm, struct token *tk)
}
vfree(&rest);
}
+ if (in_range(t, TKWBEGIN_, TKWEND_) && (tk = tk ? tk : tk_)->extwarn) {
+ static struct bitset already[BSSIZE(TKWEND_-TKWBEGIN_+1)];
+ if (!bstest(already, t-TKWBEGIN_)) {
+ bsset(already, t-TKWBEGIN_);
+ warn(&tk->span, "%'tk in %M is an extension", tk);
+ }
+ }
return t;
}
#define lex(Cm,Tk) lexc(Cm,Tk)
diff --git a/c/lex.c b/c/lex.c
index afadffc..548f82c 100644
--- a/c/lex.c
+++ b/c/lex.c
@@ -33,6 +33,7 @@ identkeyword(struct token *tk, const char *s, int len)
};
int l = 0, h = arraylength(kwtab) - 1, i, cmp;
+ tk->extwarn = 0;
if (len > TKWMAXLEN_) goto ident;
/* binary search over sorted array */
while (l <= h) {
@@ -579,8 +580,7 @@ Begin:
}
tmp[n] = 0;
if (!identkeyword(tk, tmp, n) && ccopt.pedant)
- warn(&(struct span) {{ idx, lx->chridx - idx, lx->fileid }},
- "%'tk in %M is an extension", tk);
+ tk->extwarn = 1;
goto End;
}
case 0: if (lx->idx >= lx->ndat) RET(TKEOF);
diff --git a/c/lex.h b/c/lex.h
index fd84f0a..9791340 100644
--- a/c/lex.h
+++ b/c/lex.h
@@ -54,6 +54,7 @@ struct token {
bool litlit;
uchar wide : 2; /* for CHRLIT & STRLIT; 1 -> 16bit, 2 -> 32bit */
uchar wideuni : 1; /* ditto, 0 -> 'L', 1 -> 'u'/'U' (C11) */
+ uchar extwarn : 1; /* warn this keyword token is an extension */
union {
uint len;
struct { ushort macidx, argidx; };