]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/24306 (va_arg gets confused when skipping over certain zero-sized...
authorRichard Guenther <rguenther@suse.de>
Tue, 20 Dec 2005 16:20:27 +0000 (16:20 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 20 Dec 2005 16:20:27 +0000 (16:20 +0000)
2005-12-20  Richard Guenther  <rguenther@suse.de>

PR middle-end/24306
* builtins.c (std_gimplify_va_arg_expr): Do not align
va frame for zero sized types.
* config/i386/i386.c (ix86_gimplify_va_arg): Likewise.

        * gcc.target/i386/pr24306.c: New testcase.

From-SVN: r108854

gcc/ChangeLog
gcc/builtins.c
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr24306.c [new file with mode: 0644]

index 021b23a02b3f23372e111816fedda0a831cbb140..3c7451058f2a5604739fc81214616b4b15faccae 100644 (file)
@@ -1,3 +1,10 @@
+2005-12-20  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/24306
+       * builtins.c (std_gimplify_va_arg_expr): Do not align
+       va frame for zero sized types.
+       * config/i386/i386.c (ix86_gimplify_va_arg): Likewise.
+
 2005-12-20  Kazu Hirata  <kazu@codesourcery.com>
 
        PR tree-optimization/25501
index 29ec05c7272ff4392675b2e0ffc3168f0e61a792..7c5711195b570a277d51c1d0a2bf5b8906a71787 100644 (file)
@@ -4162,7 +4162,8 @@ std_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p)
 
   /* va_list pointer is aligned to PARM_BOUNDARY.  If argument actually
      requires greater alignment, we must perform dynamic alignment.  */
-  if (boundary > align)
+  if (boundary > align
+      && !integer_zerop (TYPE_SIZE (type)))
     {
       t = fold_convert (TREE_TYPE (valist), size_int (boundary - 1));
       t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp,
index 86864d2d82c27f93c7c9e62b038eee299c5a39dc..48e3a2a9293bd33eacb182f7b66d0bb60b558932 100644 (file)
@@ -4074,7 +4074,8 @@ ix86_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p)
   /* ... otherwise out of the overflow area.  */
 
   /* Care for on-stack alignment if needed.  */
-  if (FUNCTION_ARG_BOUNDARY (VOIDmode, type) <= 64)
+  if (FUNCTION_ARG_BOUNDARY (VOIDmode, type) <= 64
+      || integer_zerop (TYPE_SIZE (type)))
     t = ovf;
   else
     {
index 3fec3a6f1eba434182df1c5c4ff50a625fbfc497..5b21ca83a14ca23bdacc3a5da54ed58ce208d9e4 100644 (file)
@@ -1,3 +1,8 @@
+2005-12-20  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/24306
+       * gcc.target/i386/pr24306.c: New testcase.
+
 2005-12-20  Kazu Hirata  <kazu@codesourcery.com>
 
        PR tree-optimization/25501
diff --git a/gcc/testsuite/gcc.target/i386/pr24306.c b/gcc/testsuite/gcc.target/i386/pr24306.c
new file mode 100644 (file)
index 0000000..61aca39
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-options "-msse" } */
+
+extern void abort(void);
+typedef int __attribute__ ((vector_size (16))) foo_t;
+
+struct s
+{
+  foo_t f[0];
+} s1;
+
+void
+check (int x, ...) __attribute__((noinline));
+void
+check (int x, ...)
+{
+  int y;
+  __builtin_va_list ap;
+
+  __builtin_va_start (ap, x);
+  __builtin_va_arg (ap, struct s);
+  y = __builtin_va_arg (ap, int);
+
+  if (y != 7)
+    abort ();
+}
+
+int main()
+{
+  check (3, s1, 7);
+  return 0;
+}