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]
Other format: [Raw text]

[PATCH] Fix PR40023


Build the correct types.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2009-05-05  Richard Guenther  <rguenther@suse.de>

	PR middle-end/40023
	* builtins.c (gimplify_va_arg_expr): Properly build the
	address.

	* gcc.c-torture/compile/pr40023.c: New testcase.

Index: gcc/builtins.c
===================================================================
*** gcc/builtins.c	(revision 147094)
--- gcc/builtins.c	(working copy)
*************** gimplify_va_arg_expr (tree *expr_p, gimp
*** 5033,5039 ****
  	  if (TREE_CODE (TREE_TYPE (valist)) == ARRAY_TYPE)
  	    {
  	      tree p1 = build_pointer_type (TREE_TYPE (have_va_type));
! 	      valist = build_fold_addr_expr_with_type (valist, p1);
  	    }
  
  	  gimplify_expr (&valist, pre_p, post_p, is_gimple_val, fb_rvalue);
--- 5033,5039 ----
  	  if (TREE_CODE (TREE_TYPE (valist)) == ARRAY_TYPE)
  	    {
  	      tree p1 = build_pointer_type (TREE_TYPE (have_va_type));
! 	      valist = fold_convert (p1, build_fold_addr_expr (valist));
  	    }
  
  	  gimplify_expr (&valist, pre_p, post_p, is_gimple_val, fb_rvalue);
Index: gcc/testsuite/gcc.c-torture/compile/pr40023.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr40023.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr40023.c	(revision 0)
***************
*** 0 ****
--- 1,11 ----
+ typedef __builtin_va_list va_list;
+ typedef struct {
+     va_list ap;
+ } ScanfState;
+ void
+ GetInt(ScanfState *state, long llval)
+ {
+   *__builtin_va_arg(state->ap,long *) = llval;
+   __builtin_va_end(state->ap);
+ }
+ 


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