From: MaartenBrock Date: Tue, 6 Feb 2007 23:33:52 +0000 (+0000) Subject: * support/regression/tests/bug1273984.c: new, added, thanks Günther Jehle X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=d35c87482d5213924279b193f3c581916777c4b1;p=fw%2Fsdcc * support/regression/tests/bug1273984.c: new, added, thanks Günther Jehle git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4622 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- 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); + +} + +