]> git.gag.com Git - fw/sdcc/commitdiff
* src/SDCCicode.c (geniCodePreInc, geniCodePreDec, ast2iCode):
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 19 Oct 2003 04:39:13 +0000 (04:39 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 19 Oct 2003 04:39:13 +0000 (04:39 +0000)
Fixed bug #818696
* src/SDCCast.c (ast_print): Fixed --dumptree so that preincrement
and predecrement operand is displayed

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2954 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCast.c
src/SDCCicode.c

index fd4ce6377fc0c16c7251fd8cf9eddd9261ed11f3..b242f43f8810a7cdf51fbc54abd408b1dcc027d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-10-19 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+       * src/SDCCicode.c (geniCodePreInc, geniCodePreDec, ast2iCode):
+       Fixed bug #818696
+       * src/SDCCast.c (ast_print): Fixed --dumptree so that preincrement
+       and predecrement operand is displayed
+
 2003-10-13 Bernhard Held <bernhard@bernhardheld.de>
 
        * src/SDCCval.c (valMinus): fixed bug #826041
index f1cc4b7828d35ad5e003e75d104e5f045b8d6284..0c160a1bc7c0eb2d167eab9fd92813b7f144002d 100644 (file)
@@ -1596,7 +1596,7 @@ isConformingBody (ast * pbody, symbol * sym, ast * body)
       return TRUE;
 
 /*------------------------------------------------------------------*/
-    case INC_OP:               /* incerement operator unary so left only */
+    case INC_OP:
     case DEC_OP:
 
       /* sure we are not sym is not modified */
@@ -2221,7 +2221,7 @@ decorateType (ast * tree)
       /*----------------------------*/
       /*  ++/-- operation           */
       /*----------------------------*/
-    case INC_OP:               /* increment operator unary so left only */
+    case INC_OP:
     case DEC_OP:
       {
        sym_link *ltc = (tree->right ? RTYPE (tree) : LTYPE (tree));
@@ -4985,18 +4985,28 @@ void ast_print (ast * tree, FILE *outfile, int indent)
                /*----------------------------*/
                /*  ++/-- operation           */
                /*----------------------------*/
-       case INC_OP:            /* incerement operator unary so left only */
+       case INC_OP:
+               if (tree->left)
+                 fprintf(outfile,"post-");
+               else
+                 fprintf(outfile,"pre-");
                fprintf(outfile,"INC_OP (%p) type (",tree);
                printTypeChain(tree->ftype,outfile);
                fprintf(outfile,")\n");
-               ast_print(tree->left,outfile,indent+2);
+               ast_print(tree->left,outfile,indent+2); /* postincrement case */
+               ast_print(tree->right,outfile,indent+2); /* preincrement case */
                return ;
 
        case DEC_OP:
+               if (tree->left)
+                 fprintf(outfile,"post-");
+               else
+                 fprintf(outfile,"pre-");
                fprintf(outfile,"DEC_OP (%p) type (",tree);
                printTypeChain(tree->ftype,outfile);
                fprintf(outfile,")\n");
-               ast_print(tree->left,outfile,indent+2);
+               ast_print(tree->left,outfile,indent+2); /* postdecrement case */
+               ast_print(tree->right,outfile,indent+2); /* predecrement case */
                return ;
 
                /*------------------------------------------------------------------*/
index eef790d2fe8894d1ed9b01ace2d8b18bcd465b3d..99996df959a873dbac74630a6e1debb1f9c9d63c 100644 (file)
@@ -2226,7 +2226,7 @@ geniCodeArray (operand * left, operand * right,int lvl)
 {
   iCode *ic;
   sym_link *ltype = operandType (left);
-
+  
   if (IS_PTR (ltype))
     {
       if (IS_PTR (ltype->next) && left->isaddr)
@@ -2258,6 +2258,7 @@ geniCodeArray (operand * left, operand * right,int lvl)
 
   IC_RESULT (ic)->isaddr = (!IS_AGGREGATE (ltype->next));
   ADDTOCHAIN (ic);
+  
   return IC_RESULT (ic);
 }
 
@@ -2348,7 +2349,7 @@ geniCodePostInc (operand * op)
 /* geniCodePreInc - generate code for preIncrement                 */
 /*-----------------------------------------------------------------*/
 operand *
-geniCodePreInc (operand * op)
+geniCodePreInc (operand * op, bool lvalue)
 {
   iCode *ic;
   sym_link *optype = operandType (op);
@@ -2374,8 +2375,11 @@ geniCodePreInc (operand * op)
   IC_RESULT (ic) = result = newiTempOperand (roptype, 0);
   ADDTOCHAIN (ic);
 
-
-  return geniCodeAssign (op, result, 0);
+  (void) geniCodeAssign (op, result, 0);
+  if (lvalue)
+    return op;
+  else
+    return result;
 }
 
 /*-----------------------------------------------------------------*/
@@ -2428,7 +2432,7 @@ geniCodePostDec (operand * op)
 /* geniCodePreDec - generate code for pre  decrement               */
 /*-----------------------------------------------------------------*/
 operand *
-geniCodePreDec (operand * op)
+geniCodePreDec (operand * op, bool lvalue)
 {
   iCode *ic;
   sym_link *optype = operandType (op);
@@ -2454,8 +2458,11 @@ geniCodePreDec (operand * op)
   IC_RESULT (ic) = result = newiTempOperand (roptype, 0);
   ADDTOCHAIN (ic);
 
-
-  return geniCodeAssign (op, result, 0);
+  (void) geniCodeAssign (op, result, 0);
+  if (lvalue)
+    return op;
+  else
+    return result;
 }
 
 
@@ -3612,13 +3619,13 @@ ast2iCode (ast * tree,int lvl)
       if (left)
        return geniCodePostInc (left);
       else
-       return geniCodePreInc (right);
+       return geniCodePreInc (right, tree->lvalue);
 
     case DEC_OP:               /* decrement operator */
       if (left)
        return geniCodePostDec (left);
       else
-       return geniCodePreDec (right);
+       return geniCodePreDec (right, tree->lvalue);
 
     case '&':                  /* bitwise and or address of operator */
       if (right)