This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR40023
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 5 May 2009 18:06:47 +0200 (CEST)
- Subject: [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);
+ }
+