commit 4ddd2d61847e132b3ced1e658d47e91529ab646f
parent e01112494a77bdf62e63e5332eb867def79c9326
Author: Michael Forney <mforney@mforney.org>
Date: Fri, 17 Feb 2017 13:34:23 -0800
[cc2] Add missing * case to assign subop
This fixes *= assignment, which previously triggered a stack underflow.
Also, re-order the cases to match optbl.
Diffstat:
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git 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
@@ -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;
}