[hackers] [scc] Convert errors in Case() in semantic errors || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 28 Nov 2015 16:20:43 +0100 (CET)

commit 5884598d6118dbbe909880ee6c6a1e38cd602478
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Nov 28 16:00:02 2015 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Nov 28 16:20:29 2015 +0100

    Convert errors in Case() in semantic errors
    
    Again, it is not needed to recover in this case.

diff --git a/cc1/stmt.c b/cc1/stmt.c
index a16f458..244aabd 100644
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
_AT_@ -238,17 +238,20 @@ Case(Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
 
         expect(CASE);
         if (!lswitch)
- error("case label not within a switch statement");
+ errorp("case label not within a switch statement");
         if ((np = iconstexpr()) == NULL)
- error("case label does not reduce to an integer constant");
+ errorp("case label does not reduce to an integer constant");
         expect(':');
- pcase = xmalloc(sizeof(*pcase));
- pcase->expr = np;
- pcase->next = lswitch->head;
- emit(OLABEL, pcase->label = newlabel());
- lswitch->head = pcase;
- if (++lswitch->nr == NR_SWITCH)
- error("too case labels for a switch statement");
+ if (lswitch) {
+ pcase = xmalloc(sizeof(*pcase));
+ pcase->expr = np;
+ pcase->next = lswitch->head;
+ emit(OLABEL, pcase->label = newlabel());
+ lswitch->head = pcase;
+ if (++lswitch->nr == NR_SWITCH)
+ errorp("too case labels for a switch statement");
+ /* TODO: Avoid repetion of this error for the same switch */
+ }
         stmt(lbreak, lcont, lswitch);
 }
 
Received on Sat Nov 28 2015 - 16:20:43 CET

This archive was generated by hypermail 2.3.0 : Sat Nov 28 2015 - 16:24:12 CET