From f606ec763d532f549199fe12819f7ae7f0db7c3d Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Tue, 4 Mar 2008 14:09:24 +0000 Subject: [PATCH] * src/SDCCptropt.c (ptrPseudoSymConvert): fixed bug 1536762 * support/regression/tests/bug1536762.c: new, added git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5067 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCptropt.c | 8 ++-- support/regression/tests/bug1536762.c | 60 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 support/regression/tests/bug1536762.c diff --git a/src/SDCCptropt.c b/src/SDCCptropt.c index 85d94709..b3ff931f 100644 --- a/src/SDCCptropt.c +++ b/src/SDCCptropt.c @@ -249,7 +249,7 @@ ptrBaseRematSym (symbol *ptrsym) /*--------------------------------------------------------------------*/ -/* ptrPseudoSymSafe - check to see if the convertion of the result of */ +/* ptrPseudoSymSafe - check to see if the conversion of the result of */ /* a pointerGet of a rematerializable pointer to a pseudo symbol is */ /* safe. Returns true if safe, or false if hazards were detected. */ /*--------------------------------------------------------------------*/ @@ -375,10 +375,10 @@ void ptrPseudoSymConvert (symbol *sym, iCode *dic, char *name) { symbol *psym = newSymbol (name, 1); - psym->type = sym->type; - psym->etype = sym->etype; psym->psbase = ptrBaseRematSym (OP_SYMBOL (IC_LEFT (dic))); - + psym->type = sym->type; + psym->etype = psym->psbase->etype; + strcpy (psym->rname, psym->name); sym->isspilt = 1; sym->usl.spillLoc = psym; diff --git a/support/regression/tests/bug1536762.c b/support/regression/tests/bug1536762.c new file mode 100644 index 00000000..8c90163b --- /dev/null +++ b/support/regression/tests/bug1536762.c @@ -0,0 +1,60 @@ +/* + bug1536762.c +*/ + +#include +#include +#include + +xdata uint8_t c = 1; + +struct d { + xdata struct d *n; + uint8_t f; + uint8_t s; + xdata uint8_t *buffer; + uint16_t length; +}; + + +xdata struct d xd = {&xd, 1, 0xab, &c, 3}; + + +struct { + xdata struct d *c; + int16_t count; + xdata uint8_t *bptr; +} s = {&xd, -1, &c}; + + +void blurb(void) +{ + if (s.count < 0) { + s.c->s = 0xef; + s.count = s.c->length - 1; + s.bptr = s.c->buffer; + } + *s.bptr = 0; + s.bptr++; + s.count--; +} + + +void +testBug(void) +{ + ASSERT(xd.s == 0xab); + ASSERT(s.c->s == 0xab); + + s.c->s = 0xcd; + + ASSERT(xd.s == 0xcd); + ASSERT(s.c->s == 0xcd); + + blurb(); + + ASSERT(xd.s == 0xef); + ASSERT(s.c->s == 0xef); + ASSERT(c == 0); +} + -- 2.30.2