From d70c76fd171b223c3e1974b77dfc1644a0753cfe Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Wed, 20 Feb 2008 18:21:56 +0000 Subject: [PATCH] * src/SDCClrange.c (findPrevUse): fixed bug 1888147 * 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 | 5 +++++ src/SDCClrange.c | 20 +++++++++++++------- support/regression/tests/bug1888147.c | 22 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 support/regression/tests/bug1888147.c diff --git a/ChangeLog b/ChangeLog index f18af531..49458173 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-02-20 Maarten Brock + + * src/SDCClrange.c (findPrevUse): fixed bug 1888147 + * support/regression/tests/bug1888147.c: new, added + 2008-02-20 Philipp Klaus Krause * src/z80/gen.c: fixed bugs #1596270, #1736867 diff --git a/src/SDCClrange.c b/src/SDCClrange.c index 91c31cfd..c4a5bcc2 100644 --- a/src/SDCClrange.c +++ b/src/SDCClrange.c @@ -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 index 00000000..a9673a91 --- /dev/null +++ b/support/regression/tests/bug1888147.c @@ -0,0 +1,22 @@ +/* + bug 1888147 +*/ + +#include + +// 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); +} -- 2.30.2