scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 18602f1f32899cb74170a42ec4a1dc90fcb093b9
parent 3eb5942278feaee4a0644ac7fed545ba19c052e6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 21 Apr 2014 10:29:32 +0200

Avoid operations like i += p

We are swapping the operands of arithmetic operations when
there is a pointer operand, but it cannot be done when
the operator is a short form of assignment, because in this
case we could assign a pointer to an integer.

Diffstat:
Mexpr.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/expr.c b/expr.c @@ -157,7 +157,8 @@ arithmetic(char op, Node *np1, Node *np2) case ARY: np2 = addr2ptr(np2); case PTR: - return parithmetic(op, np2, np1); + if (op == OADD || op == OSUB) + return parithmetic(op, np2, np1); default: goto incorrect; }