[hackers] [scc] [cc2] Add missing * case to assign subop || Michael Forney

From: <git_AT_suckless.org>
Date: Fri, 17 Feb 2017 22:48:55 +0100 (CET)

commit 4ddd2d61847e132b3ced1e658d47e91529ab646f
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Fri Feb 17 13:34:23 2017 -0800
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Feb 17 22:48:48 2017 +0100

    [cc2] Add missing * case to assign subop
    
    This fixes *= assignment, which previously triggered a stack underflow.
    
    Also, re-order the cases to match optbl.

diff --git a/cc2/parser.c b/cc2/parser.c
index 8dd0e75..f19f5f0 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
_AT_@ -253,10 +253,11 @@ assign(char *token, union tokenop u)
         Node *np = newnode(u.op);
 
         switch (subop = *++token) {
- case '/':
- case '%':
         case '+':
         case '-':
+ case '*':
+ case '%':
+ case '/':
         case 'l':
         case 'r':
         case '&':
diff --git a/tests/execute/0037-assignop.c b/tests/execute/0037-assignop.c
index df5cb89..7a387c0 100644
--- a/tests/execute/0037-assignop.c
+++ b/tests/execute/0037-assignop.c
_AT_@ -9,9 +9,12 @@ main()
         x += 2;
         if (x != 4)
                 return 1;
- x -= 3;
- if (x != 1)
+ x -= 1;
+ if (x != 3)
                 return 2;
+ x *= 2;
+ if (x != 6)
+ return 3;
                 
         return 0;
 }
Received on Fri Feb 17 2017 - 22:48:55 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 17 2017 - 23:00:18 CET