scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 5a7f4ee3d6a0643520098f73ecb93b4202bb5133
parent 5b666be8a5986e9d7f82d7877b9678429bfb3d55
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 26 Sep 2015 09:49:16 +0200

Fix toomany error control

There are variables called 'toomany' in several places
to avoid repeat the same error a number of times, but
the logic was wrong and they were not only disabling
the error, but the error recovery code to.

Diffstat:
Mcc1/expr.c | 21+++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -554,8 +554,9 @@ arguments(Node *np) do { arg = decay(assign()); - if (--n < 0 && !toomany) { - errorp("too many arguments in function call"); + if (--n < 0) { + if (!toomany) + errorp("too many arguments in function call"); toomany = 1; continue; } @@ -1071,17 +1072,19 @@ initlist(Symbol *sym, Type *tp) } switch (tp->op) { case ARY: - if (tp->defined && n >= tp->n.elem && !toomany) { + if (tp->defined && n >= tp->n.elem) { + if (!toomany) + warn("excess elements in array initializer"); toomany = 1; - warn("excess elements in array initializer"); sym = NULL; } newtp = tp->type; break; case STRUCT: - if (n >= tp->n.elem && !toomany) { + if (n >= tp->n.elem) { + if (!toomany) + warn("excess elements in struct initializer"); toomany = 1; - warn("excess elements in struct initializer"); sym = NULL; } else { sym = tp->p.fields[n]; @@ -1091,9 +1094,11 @@ initlist(Symbol *sym, Type *tp) default: newtp = tp; warn("braces around scalar initializer"); - if (n > 0 && !toomany) { + if (n > 0) { + if (!toomany) + warn("excess elements in scalar initializer"); toomany = 1; - warn("excess elements in scalar initializer"); + sym = NULL; } break; }