From: MaartenBrock Date: Fri, 1 May 2009 18:36:36 +0000 (+0000) Subject: * src/SDCCast.c (processParms): fixed bug 2783061 by applying patch from X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=d5ab1063b007b38a948cfbae6d4efab7908f4e30;p=fw%2Fsdcc * src/SDCCast.c (processParms): fixed bug 2783061 by applying patch from Keith Packard, thanks * support/regression/tests/bug2783061.c: new, added git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5445 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 00df7cfa..e3a197ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-05-01 Maarten Brock + + * src/SDCCast.c (processParms): fixed bug 2783061 by applying patch from + Keith Packard, thanks + * support/regression/tests/bug2783061.c: new, added + 2009-04-27 Borut Razem * support/cpp/output.h, support/cpp/opts-common.c, @@ -157,7 +163,7 @@ 2009-04-01 Philipp Klaus Krause - * device/lib/z80/mul.s: + * device/lib/z80/mul.s: Minor improvement in Z80 16x16 bit multiplication. 2009-03-23 Borut Razem diff --git a/src/SDCCast.c b/src/SDCCast.c index 39140831..3470ac46 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -863,6 +863,8 @@ processParms (ast *func, ftype = (*actParm)->ftype; + resultType = RESULT_TYPE_NONE; + /* If it's a char, upcast to int. */ if (IS_INTEGRAL (ftype) && (getSize (ftype) < (unsigned) INTSIZE)) @@ -874,12 +876,14 @@ processParms (ast *func, { newType = newAst_LINK (copyLinkChain(ftype)); DCL_TYPE (newType->opval.lnk) = port->unqualified_pointer; + resultType = RESULT_TYPE_GPTR; } if (IS_AGGREGATE (ftype)) { newType = newAst_LINK (copyLinkChain (ftype)); DCL_TYPE (newType->opval.lnk) = port->unqualified_pointer; + resultType = RESULT_TYPE_GPTR; } if (newType) @@ -890,7 +894,7 @@ processParms (ast *func, (*actParm)->filename = (*actParm)->right->filename; (*actParm)->lineno = (*actParm)->right->lineno; - decorateType (*actParm, RESULT_TYPE_NONE); + decorateType (*actParm, resultType); } return 0; } /* vararg */ diff --git a/support/regression/tests/bug2783061.c b/support/regression/tests/bug2783061.c new file mode 100644 index 00000000..c439c30c --- /dev/null +++ b/support/regression/tests/bug2783061.c @@ -0,0 +1,39 @@ +/* + bug 2783061 +*/ + +#include +#include + +#define CP (void code*)0x1234 +#define XP (void xdata*)0x5678 + +void varargs_fn(char k, ...) +{ + va_list arg; + void code * cp; + void xdata * xp; + void * gp; + + va_start (arg, k); + + cp = va_arg(arg, void code *); + ASSERT(cp == CP); + xp = va_arg(arg, void xdata *); + ASSERT(xp == XP); + gp = va_arg(arg, void *); + ASSERT(gp == (void *)CP); + gp = va_arg(arg, void *); + ASSERT(gp == (void *)XP); + + va_end (arg); +} + +void +testBug(void) +{ + void code * cp = CP; + void xdata * xp = XP; + + varargs_fn('k', (void code *)cp, (void xdata *)xp, cp, xp); +}