~mcf/cproc

c557c2dbe484a725ae9233b706dffc2a184bdcc2 — Michael Forney 1 year, 7 months ago 185261f
expr: Use tokstr in ++/-- operator error messages
3 files changed, 4 insertions(+), 3 deletions(-)

M cc.h
M expr.c
M token.c
M cc.h => cc.h +1 -0
@@ 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 *);

M expr.c => expr.c +2 -2
@@ 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;

M token.c => token.c +1 -1
@@ 9,7 9,7 @@

struct token tok;

static const char *tokstr[] = {
const char *tokstr[] = {
	/* keyword */
	[TAUTO] = "auto",
	[TBREAK] = "break",