From d35c87482d5213924279b193f3c581916777c4b1 Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Tue, 6 Feb 2007 23:33:52 +0000 Subject: [PATCH] =?utf8?q?*=20support/regression/tests/bug1273984.c:=20new?= =?utf8?q?,=20added,=20thanks=20G=C3=BCnther=20Jehle?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4622 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 1 + support/regression/tests/bug1273984.c | 43 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 support/regression/tests/bug1273984.c diff --git a/ChangeLog b/ChangeLog index 122901e5..48808425 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ can this have lived here for so many years? * src/SDCCicode.c (ast2iCode): return left instead of right for assignment, fixes bug 1273984, see also patch 1645121, thanks Günther Jehle + * support/regression/tests/bug1273984.c: new, added, thanks Günther Jehle 2007-02-06 Bernhard Held diff --git a/support/regression/tests/bug1273984.c b/support/regression/tests/bug1273984.c new file mode 100644 index 00000000..1006a307 --- /dev/null +++ b/support/regression/tests/bug1273984.c @@ -0,0 +1,43 @@ +/* An assignment inside a functioncall changed the type of the parameter. + See bug description 1273984 for details. + + Bug detected and fixed by Guenther Jehle + + sign: unsigned, + */ + +#include + +void foo({sign} int val) { + val; //make the compiler happy +} + +void fooInt({sign} int val) { + ASSERT(val==3); +} + +void fooChar({sign} char val) { + ASSERT(val==6); +} + +void +testAssignInFunctioncall(void) +{ + volatile {sign} char charVal=3; + volatile {sign} int intVal=0x4040; + + fooInt(intVal=charVal); // should cast charVal to int for function call. + // without patch #1645121, a char is put on the stack + // (or hold in registers) + foo(0xAAAA); + fooInt(intVal=charVal); + + intVal=6; + + fooChar(charVal=intVal); // without patch, a int is put on the stack + foo(0xAAAA); + fooChar(charVal=intVal); + +} + + -- 2.30.2