shithub: scc

Download patch

ref: 18602f1f32899cb74170a42ec4a1dc90fcb093b9
parent: 3eb5942278feaee4a0644ac7fed545ba19c052e6
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Apr 21 06:29:32 EDT 2014

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.

--- a/expr.c
+++ b/expr.c
@@ -157,7 +157,8 @@
 		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;
 		}