This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: ppc va-arg-10 fix
- To: Richard Henderson <rth at cygnus dot com>, gcc-patches at gcc dot gnu dot org
- Subject: Re: ppc va-arg-10 fix
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Date: Sun, 3 Oct 1999 17:47:46 +0200
- Cc: Raja R Harinath <harinath at cs dot umn dot edu>
- References: <19990928011836.A6371@cygnus.com> <99092823230100.00852@ns1102.munich.netsurf.de>
Am Die, 28 Sep 1999 schrieb Franz Sirl:
>BTW, I could reproduce the va_arg problem reported by Raja R Harinath
><harinath@cs.umn.edu> on gcc-bugs on Linux/PPC as well.
Hi Richard, the appended small patch fixes it on Linux/PPC.
Franz.
* c-common.c (build_va_arg): set TREE_SIDE_EFFECTS
Index: c-common.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-common.c,v
retrieving revision 1.72
diff -u -p -r1.72 c-common.c
--- c-common.c 1999/09/24 10:06:48 1.72
+++ c-common.c 1999/10/03 15:48:10
@@ -3825,7 +3825,11 @@ tree
build_va_arg (expr, type)
tree expr, type;
{
- return build1 (VA_ARG_EXPR, type, expr);
+ tree temp;
+
+ temp = build1 (VA_ARG_EXPR, type, expr);
+ TREE_SIDE_EFFECTS (temp) = 1;
+ return temp;
}
/* Return nonzero if VALUE is a valid constant-valued expression
Testcase:
#include <stdarg.h>
void fap (int i, ...)
{
va_list ap;
va_start (ap, i);
va_arg (ap, int);
if (va_arg (ap, int) != i)
abort ();
va_end (ap);
}
int main (void)
{
fap (22, 33, 22);
exit (0);
}