aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cc.h1
-rw-r--r--expr.c4
-rw-r--r--token.c2
3 files changed, 4 insertions, 3 deletions
diff --git a/cc.h b/cc.h
index fbf6075..ec6339f 100644
--- a/cc.h
+++ b/cc.h
@@ -372,6 +372,7 @@ struct init {
/* token */
extern struct token tok;
+extern const char *tokstr[];
void tokprint(const struct token *);
void tokdesc(char *, size_t, enum tokenkind, const char *);
diff --git a/expr.c b/expr.c
index 3e2c140..9257cf2 100644
--- a/expr.c
+++ b/expr.c
@@ -659,9 +659,9 @@ unaryexpr(struct scope *s)
next();
l = unaryexpr(s);
if (!l->lvalue)
- error(&tok.loc, "operand of %srement operator must be an lvalue", op == TINC ? "inc" : "dec");
+ error(&tok.loc, "operand of '%s' operator must be an lvalue", tokstr[op]);
if (l->qual & QUALCONST)
- error(&tok.loc, "operand of %srement operator is const qualified", op == TINC ? "inc" : "dec");
+ error(&tok.loc, "operand of '%s' operator is const qualified", tokstr[op]);
e = mkexpr(EXPRINCDEC, l->type);
e->incdec.op = op;
e->incdec.base = l;
diff --git a/token.c b/token.c
index 3a97f7a..0ead68e 100644
--- a/token.c
+++ b/token.c
@@ -9,7 +9,7 @@
struct token tok;
-static const char *tokstr[] = {
+const char *tokstr[] = {
/* keyword */
[TAUTO] = "auto",
[TBREAK] = "break",