[hackers] [scc] Fix labelled statements || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 11 Aug 2015 17:57:55 +0200 (CEST)

commit 31704f8d6cf7fe145c2e7c0109f46bf9a175bd21
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Aug 11 16:11:26 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Aug 11 16:11:26 2015 +0200

    Fix labelled statements
    
    After a label was allowed only an expression, but the C grammar
    allows any statement.

diff --git a/cc1/stmt.c b/cc1/stmt.c
index 7a8081f..390a906 100644
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
_AT_@ -43,16 +43,14 @@ label(void)
 static void
 stmtexp(Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
 {
- Node *np;
-
- if (ahead() == ':')
+ if (accept(';'))
+ return;
+ if (ahead() == ':') {
                 label();
-
- if (yytoken != ';') {
- np = expr();
- emit(OEXPR, np);
+ stmt(lbreak, lcont, lswitch);
+ return;
         }
-
+ emit(OEXPR, expr());
         expect(';');
 }
 
Received on Tue Aug 11 2015 - 17:57:55 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 11 2015 - 18:00:17 CEST