* src/mcs51/gen.c (genPagedPointerSet): fixed bug 1670148
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 25 Feb 2008 22:12:52 +0000 (22:12 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 25 Feb 2008 22:12:52 +0000 (22:12 +0000)
* support/regression/ports/mcs51-xstack-auto/spec.mk: added expf.c
* support/regression/tests/bug1670148.c: new, added

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

ChangeLog
src/mcs51/gen.c
support/regression/ports/mcs51-xstack-auto/spec.mk
support/regression/tests/bug1670148.c [new file with mode: 0644]

index 03ec0a712ad127555b37cba1c9ecf2af26848d11..ada7111092898de6fa299f01c95fbceb6ef63653 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-25 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/mcs51/gen.c (genPagedPointerSet): fixed bug 1670148
+       * support/regression/ports/mcs51-xstack-auto/spec.mk: added expf.c
+       * support/regression/tests/bug1670148.c: new, added
+
 2008-02-25 Jesus Calvino-Fraga <jesusc AT ece.ubc.ca>
 
        * device/include/mcs51/at89c51ed2.h: fixed bug 1901469.
index a0960b8821ac2d0a4a1ee40611ea8b5ba0edf931..8fb85cad76451b20c4a5c4474abc462c8bc3a0d5 100644 (file)
@@ -10603,39 +10603,36 @@ genNearPointerSet (operand * right,
      then don't need anything more */
   if (!AOP_INPREG (AOP (result)))
     {
-        if (
-            //AOP_TYPE (result) == AOP_STK
-            IS_AOP_PREG(result)
-            )
+      if (IS_AOP_PREG (result))
         {
-            // Aha, it is a pointer, just in disguise.
-            rname = aopGet (result, 0, FALSE, FALSE);
-            if (*rname != '@')
+          // Aha, it is a pointer, just in disguise.
+          rname = aopGet (result, 0, FALSE, FALSE);
+          if (*rname != '@')
             {
-                fprintf(stderr, "probable internal error: unexpected rname @ %s:%d\n",
-                        __FILE__, __LINE__);
+              fprintf(stderr, "probable internal error: unexpected rname @ %s:%d\n",
+                      __FILE__, __LINE__);
             }
-            else
+          else
             {
-                // Expected case.
-                emitcode ("mov", "a%s,%s", rname + 1, rname);
-                rname++;  // skip the '@'.
+              // Expected case.
+              emitcode ("mov", "a%s,%s", rname + 1, rname);
+              rname++;  // skip the '@'.
             }
         }
-        else
+      else
         {
-            /* otherwise get a free pointer register */
-            aop = newAsmop (0);
-            preg = getFreePtr (ic, &aop, FALSE);
-            emitcode ("mov", "%s,%s",
-                      preg->name,
-                      aopGet (result, 0, FALSE, TRUE));
-            rname = preg->name;
+          /* otherwise get a free pointer register */
+          aop = newAsmop (0);
+          preg = getFreePtr (ic, &aop, FALSE);
+          emitcode ("mov", "%s,%s",
+                    preg->name,
+                    aopGet (result, 0, FALSE, TRUE));
+          rname = preg->name;
         }
     }
-    else
+  else
     {
-        rname = aopGet (result, 0, FALSE, FALSE);
+      rname = aopGet (result, 0, FALSE, FALSE);
     }
 
   aopOp (right, ic, FALSE);
@@ -10723,16 +10720,37 @@ genPagedPointerSet (operand * right,
      then don't need anything more */
   if (!AOP_INPREG (AOP (result)))
     {
-      /* otherwise get a free pointer register */
-      aop = newAsmop (0);
-      preg = getFreePtr (ic, &aop, FALSE);
-      emitcode ("mov", "%s,%s",
-                preg->name,
-                aopGet (result, 0, FALSE, TRUE));
-      rname = preg->name;
+      if (IS_AOP_PREG (result))
+        {
+          // Aha, it is a pointer, just in disguise.
+          rname = aopGet (result, 0, FALSE, FALSE);
+          if (*rname != '@')
+            {
+              fprintf(stderr, "probable internal error: unexpected rname @ %s:%d\n",
+                      __FILE__, __LINE__);
+            }
+          else
+            {
+              // Expected case.
+              emitcode ("mov", "a%s,%s", rname + 1, rname);
+              rname++;  // skip the '@'.
+            }
+        }
+      else
+        {
+          /* otherwise get a free pointer register */
+          aop = newAsmop (0);
+          preg = getFreePtr (ic, &aop, FALSE);
+          emitcode ("mov", "%s,%s",
+                    preg->name,
+                    aopGet (result, 0, FALSE, TRUE));
+          rname = preg->name;
+        }
     }
   else
-    rname = aopGet (result, 0, FALSE, FALSE);
+    {
+      rname = aopGet (result, 0, FALSE, FALSE);
+    }
 
   aopOp (right, ic, FALSE);
 
@@ -10741,7 +10759,7 @@ genPagedPointerSet (operand * right,
     genPackBits ((IS_BITFIELD (retype) ? retype : letype), right, rname, PPOINTER);
   else
     {
-      /* we have can just get the values */
+      /* we can just get the values */
       int size = AOP_SIZE (right);
       int offset = 0;
 
@@ -10750,10 +10768,8 @@ genPagedPointerSet (operand * right,
           l = aopGet (right, offset, FALSE, TRUE);
           MOVA (l);
           emitcode ("movx", "@%s,a", rname);
-
           if (size || pi)
             emitcode ("inc", "%s", rname);
-
           offset++;
         }
     }
@@ -10772,10 +10788,11 @@ genPagedPointerSet (operand * right,
          if size > 0 && this could be used again
          we have to point it back to where it
          belongs */
-      if (AOP_SIZE (right) > 1 &&
+      if ((AOP_SIZE (right) > 1 &&
           !OP_SYMBOL (result)->remat &&
           (OP_SYMBOL (result)->liveTo > ic->seq ||
-           ic->depth))
+            ic->depth)) &&
+          !pi)
         {
           int size = AOP_SIZE (right) - 1;
           while (size--)
@@ -10784,9 +10801,10 @@ genPagedPointerSet (operand * right,
     }
 
   /* done */
-  if (pi) pi->generated = 1;
-  freeAsmop (result, NULL, ic, TRUE);
+  if (pi)
+    pi->generated = 1;
   freeAsmop (right, NULL, ic, TRUE);
+  freeAsmop (result, NULL, ic, TRUE);
 }
 
 /*-----------------------------------------------------------------*/
index ca07c46a9c204c65032544f09de08053d23b485c..e8ecbabb436999e9de2434963370470898515848 100644 (file)
@@ -18,7 +18,7 @@ SOURCES = _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \
           _fsadd.c _fssub.c _fsdiv.c _fsmul.c \
           _fseq.c _fsneq.c _fsgt.c _fslt.c _fscmp.c \
           fabsf.c sqrtf.c logf.c log10f.c powf.c tanf.c \
-          errno.c frexpf.c ldexpf.c tancotf.c \
+          errno.c frexpf.c ldexpf.c expf.c tancotf.c \
           _fsget1arg.c _fsget2args.c _fsnormalize.c \
           _fsreturnval.c _fsrshift.c _fsswapargs.c \
           _gptrget.c _gptrput.c \
diff --git a/support/regression/tests/bug1670148.c b/support/regression/tests/bug1670148.c
new file mode 100644 (file)
index 0000000..80f1442
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+    bug 1670148.c
+*/
+
+#include <testfwk.h>
+
+// no need to call this, it generates compiler error for xstack-auto
+//   error 9: FATAL Compiler Internal Error
+struct str {
+  long  aa;
+  long  bb;
+};
+
+struct str *v1;
+
+void foo(void)
+{
+       struct str v2;
+       struct str loc;
+
+       v2.aa = 0;
+       loc.bb  =  v1->bb;
+       loc.aa  =  v1->aa - v2.aa;
+
+       loc.bb += 0;
+}
+
+void
+testBug(void)
+{
+       ASSERT(1);
+}