(geniCodeLogicAndOr): added in order to fix bug #905492,
(ast2iCode): fixed bug #905492
* support/regression/tests/bug-905492.c: added
-
+ * src/SDCCast.c (decorateType): don't decorate/process parms twice,
+ (processParms): fixed bug #927659: don't copy parms, this will clear
+ decorated flag
+ * support/regression/tests/bug-927659.c: added
+
2004-03-29 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCast.c (addCast): don't cast float to char
}
if (newType)
- {
- /* cast required; change this op to a cast. */
- ast *parmCopy = resolveSymbols (copyAst (*actParm));
-
- (*actParm)->type = EX_OP;
- (*actParm)->opval.op = CAST;
- (*actParm)->left = newType;
- (*actParm)->right = parmCopy;
- (*actParm)->decorated = 0; /* force typechecking */
- decorateType (*actParm, RESULT_TYPE_NONE);
- }
+ {
+ /* cast required; change this op to a cast. */
+ (*actParm)->decorated = 0;
+ *actParm = newNode (CAST, newType, *actParm);
+ (*actParm)->lineno = (*actParm)->right->lineno;
+
+ decorateType (*actParm, RESULT_TYPE_NONE);
+ }
return 0;
} /* vararg */
goto errorTreeReturn;
}
- {
- sym_link *functype;
- parmNumber = 1;
+ /* if there are parms, make sure that
+ parms are decorate / process / reverse only once */
+ if (!tree->right ||
+ !tree->right->decorated)
+ {
+ sym_link *functype;
+ parmNumber = 1;
- if (IS_CODEPTR(LTYPE(tree)))
- functype = LTYPE (tree)->next;
- else
- functype = LTYPE (tree);
+ if (IS_CODEPTR(LTYPE(tree)))
+ functype = LTYPE (tree)->next;
+ else
+ functype = LTYPE (tree);
- if (processParms (tree->left, FUNC_ARGS(functype),
- &tree->right, &parmNumber, TRUE)) {
- goto errorTreeReturn;
- }
-
- if ((options.stackAuto || IFFUNC_ISREENT (functype)) &&
- !IFFUNC_ISBUILTIN(functype))
- {
- reverseParms (tree->right);
- }
+ if (processParms (tree->left, FUNC_ARGS(functype),
+ &tree->right, &parmNumber, TRUE))
+ {
+ goto errorTreeReturn;
+ }
+
+ if ((options.stackAuto || IFFUNC_ISREENT (functype)) &&
+ !IFFUNC_ISBUILTIN(functype))
+ {
+ reverseParms (tree->right);
+ }
- TTYPE (tree) = functype->next;
- TETYPE (tree) = getSpec (TTYPE (tree));
- }
+ TTYPE (tree) = functype->next;
+ TETYPE (tree) = getSpec (TTYPE (tree));
+ }
return tree;
/*------------------------------------------------------------------*/
--- /dev/null
+/* bug-927659.c
+
+ double processing resp. reversing of params
+*/
+
+#include <testfwk.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+unsigned char
+foo(unsigned char a, ...) REENTRANT
+{
+ va_list argptr;
+ unsigned char b;
+
+ va_start (argptr, a);
+ b = va_arg (argptr, int);
+ va_end (argptr);
+
+ return b;
+}
+
+unsigned char
+bar(unsigned char a, unsigned char b) REENTRANT
+{
+ return b / a;
+}
+
+void
+testReverse(void)
+{
+ ASSERT(foo (0, bar (1, 2)) == 2);
+}
+
+/*************************************************************/
+
+#ifndef PORT_HOST
+void putchar (char c)
+{
+ c;
+}
+#endif
+
+void
+testAddFunc(void)
+{
+#ifndef SDCC_z80
+ char buf[5];
+ unsigned char count = 0;
+
+ count += sprintf (buf, "%d", 5);
+ ASSERT(count == 1 &&
+ buf[0] == '5' &&
+ buf[1] == '\0');
+#else
+ ASSERT(1);
+#endif
+}
+//#endif