* src/SDCCast.c (processParms): fixed bug 2783061 by applying patch from
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 1 May 2009 18:36:36 +0000 (18:36 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 1 May 2009 18:36:36 +0000 (18:36 +0000)
  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

ChangeLog
src/SDCCast.c
support/regression/tests/bug2783061.c [new file with mode: 0644]

index 00df7cfa397cf3d25fae1983dc44873237e72271..e3a197ef940582e50c1722ea1b5a66b87abdb17d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-01 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * 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 <borut.razem AT siol.net>
 
        * support/cpp/output.h, support/cpp/opts-common.c,
 
 2009-04-01 Philipp Klaus Krause <pkk AT spth.de>
 
-       * device/lib/z80/mul.s: 
+       * device/lib/z80/mul.s:
          Minor improvement in Z80 16x16 bit multiplication.
 
 2009-03-23 Borut Razem <borut.razem AT siol.net>
index 391408318222ae2d9a396d048770554239edceaf..3470ac464fd14634807ae340f78bc699ce23901d 100644 (file)
@@ -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 (file)
index 0000000..c439c30
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+    bug 2783061
+*/
+
+#include <stdarg.h>
+#include <testfwk.h>
+
+#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);
+}