This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ppc va-arg-10 fix


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);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]