[hackers] [scc] Fix toomany error control || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 26 Sep 2015 09:51:02 +0200 (CEST)

commit 5a7f4ee3d6a0643520098f73ecb93b4202bb5133
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Sep 26 09:49:16 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Sep 26 09:49:16 2015 +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.

diff --git a/cc1/expr.c b/cc1/expr.c
index 65c533e..3d66a41 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -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;
                 }
_AT_@ -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];
_AT_@ -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;
                 }
Received on Sat Sep 26 2015 - 09:51:02 CEST

This archive was generated by hypermail 2.3.0 : Sat Sep 26 2015 - 10:00:12 CEST