* src/SDCClrange.c (findPrevUse): fixed bug 1888147
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 20 Feb 2008 18:21:56 +0000 (18:21 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 20 Feb 2008 18:21:56 +0000 (18:21 +0000)
* support/regression/tests/bug1888147.c: new, added

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

ChangeLog
src/SDCClrange.c
support/regression/tests/bug1888147.c [new file with mode: 0644]

index f18af5318bae0fd5dc49e45d5b8fe841c44d933a..49458173b4d35e85aea3394d090e1bce7574ad42 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-20 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/SDCClrange.c (findPrevUse): fixed bug 1888147
+       * support/regression/tests/bug1888147.c: new, added
+
 2008-02-20 Philipp Klaus Krause <pkk AT spth.de>
 
        * src/z80/gen.c: fixed bugs #1596270, #1736867
index 91c31cfd927513a88ce2ccbaacadd14cd44ef592..c4a5bcc2959a180b2a67d7b7e5499682aa854551 100644 (file)
@@ -457,18 +457,24 @@ findPrevUse (eBBlock *ebp, iCode *ic, operand *op,
       /* computeLiveRanges() is called twice */
       if (emitWarnings)
         {
-          werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
-                    IS_ITEMP (op) ? OP_SYMBOL (op)->prereqv->name :
-                                    OP_SYMBOL (op)->name);
           if (IS_ITEMP (op))
             {
-              OP_SYMBOL (op)->prereqv->reqv = NULL;
-              OP_SYMBOL (op)->prereqv->allocreq = 1;
+              if (OP_SYMBOL (op)->prereqv)
+                {
+                  werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
+                            OP_SYMBOL (op)->prereqv->name);
+                  OP_SYMBOL (op)->prereqv->reqv = NULL;
+                  OP_SYMBOL (op)->prereqv->allocreq = 1;
+                }
+            }
+          else
+            {
+              werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
+                        OP_SYMBOL (op)->name);
             }
         }
       /* is this block part of a loop? */
-      if (IS_ITEMP (op) &&
-          ebp->depth != 0)
+      if (IS_ITEMP (op) && ebp->depth != 0)
         {
           /* extend the life range to the outermost loop */
           unvisitBlocks(ebbs, count);
diff --git a/support/regression/tests/bug1888147.c b/support/regression/tests/bug1888147.c
new file mode 100644 (file)
index 0000000..a9673a9
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+    bug 1888147
+*/
+
+#include <testfwk.h>
+
+// no need to call this, it generates compiler error:
+//   Caught signal 11: SIGSEGV
+int foo(int n)
+{
+       int i = 0;
+
+       if (i!=0)
+               return n;
+       return 0;
+}
+
+void
+testBug(void)
+{
+       ASSERT(1);
+}