commit 4ddd2d61847e132b3ced1e658d47e91529ab646f
Author:     Michael Forney <[email protected]>
AuthorDate: Fri Feb 17 13:34:23 2017 -0800
Commit:     Roberto E. Vargas Caballero <[email protected]>
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
@@ -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
@@ -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;
 }

Reply via email to