]> git.gag.com Git - fw/sdcc/blobdiff - src/SDCCast.c
fixed bug #402254
[fw/sdcc] / src / SDCCast.c
index 85ea2852e1b4b6287e8297b2f2eb58e6fa71c9be..dfb3ad05d9550b67640489dac1eafae661aab514 100644 (file)
@@ -210,7 +210,7 @@ copyAstValues (ast * dest, ast * src)
 /* copyAst - makes a copy of a given astession                     */
 /*-----------------------------------------------------------------*/
 ast *
-copyAst (ast * src)
+copyAst (ast * src) 
 {
   ast *dest;
 
@@ -256,6 +256,31 @@ exit:
 
 }
 
+/*-----------------------------------------------------------------*/
+/* removeIncDecOps: remove for side effects in *_ASSIGN's          */
+/*                  "*s++ += 3" -> "*s++ = *s++ + 3"               */
+/*-----------------------------------------------------------------*/
+ast *removeIncDecOps (ast * tree) {
+
+  // traverse the tree and remove inc/dec ops
+
+  if (!tree)
+    return NULL;
+
+  if (tree->type == EX_OP && 
+      (tree->opval.op == INC_OP || tree->opval.op == DEC_OP)) {
+    if (tree->left)
+      tree=tree->left;
+    else 
+      tree=tree->right;
+  }
+
+  tree->left=removeIncDecOps(tree->left);
+  tree->right=removeIncDecOps(tree->right);
+ return tree;
+}
+
 /*-----------------------------------------------------------------*/
 /* hasSEFcalls - returns TRUE if tree has a function call          */
 /*-----------------------------------------------------------------*/
@@ -2946,6 +2971,7 @@ decorateType (ast * tree)
       return tree;
 
 
+#if 0 // assignment operators are converted by the parser
       /*------------------------------------------------------------------*/
       /*----------------------------*/
       /*    assignment operators    */
@@ -3078,6 +3104,7 @@ decorateType (ast * tree)
       tree->opval.op = '=';
 
       return tree;
+#endif
 
       /*------------------------------------------------------------------*/
       /*----------------------------*/