diff mbox

[committed] Fix handling of invalid va_arg (PR middle-end/45461)

Message ID 20100831161458.GI1269@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Aug. 31, 2010, 4:14 p.m. UTC
Hi!

INDIRECT_REF on RHS is now invalid since MEM_REF merge, fixed thusly,
bootstrapped/regtested on x86_64-linux and i686-linux, committed as obvious.

2010-08-31  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/45461
	* builtins.c (dummy_object): Return a MEM_REF instead of INDIRECT_REF.

	* gcc.dg/pr45461.c: New test.


	Jakub
diff mbox

Patch

--- gcc/builtins.c.jj	2010-08-26 19:50:24.000000000 +0200
+++ gcc/builtins.c	2010-08-31 13:30:50.000000000 +0200
@@ -4739,7 +4739,7 @@  static tree
 dummy_object (tree type)
 {
   tree t = build_int_cst (build_pointer_type (type), 0);
-  return build1 (INDIRECT_REF, type, t);
+  return build2 (MEM_REF, type, t, t);
 }
 
 /* Gimplify __builtin_va_arg, aka VA_ARG_EXPR, which is not really a
--- gcc/testsuite/gcc.dg/pr45461.c.jj	2010-08-31 13:50:26.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr45461.c	2010-08-31 13:50:53.000000000 +0200
@@ -0,0 +1,18 @@ 
+/* PR middle-end/45461 */
+/* { dg-do compile } */
+
+#include <stdarg.h>
+
+int
+foo (int i, ...)
+{
+  short e;
+  va_list ap;
+  va_start (ap, i);
+  e = va_arg (ap, short);	/* { dg-warning "is promoted" } */
+  va_end (ap);
+  return e;
+}
+
+/* { dg-message "note: \\(so you should pass" "" {target *-*-* } 12 } */
+/* { dg-message "note: if this code" "" {target *-*-* } 12 } */