From 5948fe48b6494da15546dfe936e6507055d6e16d Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Sun, 7 Sep 2008 12:19:47 +0000 Subject: [PATCH] * as/z80/aslist.c (lstsym): changed old K&R to ANSI * src/SDCCicode.c (geniCodeCritical): fixed bug for hc08 * src/z80/gen.c (genCritical, genEndCritical): fixed bug 2077267 * support/regression/tests/bug2077267.c: new, added git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5230 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 7 +++++++ as/z80/aslist.c | 4 +--- src/SDCCicode.c | 2 +- src/z80/gen.c | 4 ++-- support/regression/tests/bug2077267.c | 28 +++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 support/regression/tests/bug2077267.c diff --git a/ChangeLog b/ChangeLog index 10751475..a025623f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-06-04 Maarten Brock + + * as/z80/aslist.c (lstsym): changed old K&R to ANSI + * src/SDCCicode.c (geniCodeCritical): fixed bug for hc08 + * src/z80/gen.c (genCritical, genEndCritical): fixed bug 2077267 + * support/regression/tests/bug2077267.c: new, added + 2008-09-05 Raphael Neider * configure.in, Makefile.common.in: add support for ccache, diff --git a/as/z80/aslist.c b/as/z80/aslist.c index 0a8293bb..b4ac0933 100644 --- a/as/z80/aslist.c +++ b/as/z80/aslist.c @@ -565,7 +565,6 @@ int flag; * int i loop counter * int j temporary * int k temporary - * char * ptr pointer to an id string * int nmsym number of symbols * int narea number of areas * sym * sp pointer to symbol structure @@ -596,8 +595,7 @@ int flag; */ VOID -lstsym(fp) -FILE *fp; +lstsym(FILE *fp) { register int c, i, j, k; int nmsym, narea; diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 6c8ee8a8..fe437728 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -3980,7 +3980,7 @@ geniCodeCritical (ast *tree, int lvl) operand *op = NULL; sym_link *type; - if (!options.stackAuto) + if (!options.stackAuto && !TARGET_IS_HC08) { type = newLink(SPECIFIER); SPEC_VOLATILE(type) = 1; diff --git a/src/z80/gen.c b/src/z80/gen.c index 773a4f66..2ef191da 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -7616,7 +7616,7 @@ genCritical (iCode *ic) //disable interrupt emit2 ("!di"); //save P/O flag - emit2 ("push af"); + _push (PAIR_AF); } } @@ -7645,7 +7645,7 @@ genEndCritical (iCode *ic) else { //restore P/O flag - emit2 ("pop af"); + _pop (PAIR_AF); //parity odd <==> P/O=0 <==> interrupt enable flag IFF2 was 0 <==> //don't enable interrupts as they were off before emit2 ("jp PO,!tlabel", tlbl->key + 100); diff --git a/support/regression/tests/bug2077267.c b/support/regression/tests/bug2077267.c new file mode 100644 index 00000000..f0b4da01 --- /dev/null +++ b/support/regression/tests/bug2077267.c @@ -0,0 +1,28 @@ +/* + bug 2077267 +*/ + +#include + +#ifndef SDCC +#define __critical +#endif + +void bug(char* x) +{ + *x = *x + 1; +} + +void +testBug(void) +{ + char x = 1; + + bug(&x); + + __critical { + bug(&x); + } + + ASSERT (x == 3); +} -- 2.30.2