re PR target/20375 (C++ ICE in assign_parm_find_entry_rtl)
authorNathan Sidwell <nathan@codesourcery.com>
Thu, 10 Mar 2005 15:04:39 +0000 (15:04 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 10 Mar 2005 15:04:39 +0000 (15:04 +0000)
PR c++/20375
* function.c (struct assign_parm_data_one): Remove last_named
field.
(assign_parm_find_data_types): Don't determine last_named.
Reorder named_parm determination.
(assign_parms): Only setup varargs on the last non-varadic
parameter.
testsuite:
PR c++/20375
* g++.dg/other/stdarg3.C: New.

From-SVN: r96237

gcc/ChangeLog
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/stdarg3.C [new file with mode: 0644]

index 948bf1741d6ec234bd8855568618e67aec9c8adb..e6a7c4ef2183f12ce9dfedc1186e5bbf1fed731c 100644 (file)
@@ -1,3 +1,13 @@
+2005-03-10  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/20375
+       * function.c (struct assign_parm_data_one): Remove last_named
+       field.
+       (assign_parm_find_data_types): Don't determine last_named.
+       Reorder named_parm determination.
+       (assign_parms): Only setup varargs on the last non-varadic
+       parameter.
+
 2005-03-10  Kazuhiro Inaoka  <inaoka.lazuhiro@renesas.com>
 
        * config/m32r/m32r.md (load_sda_base_32): New pattern.  Loads
index 9f51e92f7de0a452f2b10db9cd89b36b94dd7e92..49029a937b7231190351657e298b406a471d74d0 100644 (file)
@@ -1992,7 +1992,6 @@ struct assign_parm_data_one
   struct locate_and_pad_arg_data locate;
   int partial;
   BOOL_BITFIELD named_arg : 1;
-  BOOL_BITFIELD last_named : 1;
   BOOL_BITFIELD passed_pointer : 1;
   BOOL_BITFIELD on_stack : 1;
   BOOL_BITFIELD loaded_in_reg : 1;
@@ -2136,24 +2135,15 @@ assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm,
 
   memset (data, 0, sizeof (*data));
 
-  /* Set LAST_NAMED if this is last named arg before last anonymous args.  */
-  if (current_function_stdarg)
-    {
-      tree tem;
-      for (tem = TREE_CHAIN (parm); tem; tem = TREE_CHAIN (tem))
-       if (DECL_NAME (tem))
-         break;
-      if (tem == 0)
-       data->last_named = true;
-    }
-
-  /* Set NAMED_ARG if this arg should be treated as a named arg.  For
-     most machines, if this is a varargs/stdarg function, then we treat
-     the last named arg as if it were anonymous too.  */
-  if (targetm.calls.strict_argument_naming (&all->args_so_far))
-    data->named_arg = 1;
+  /* NAMED_ARG is a mis-nomer.  We really mean 'non-varadic'. */
+  if (!current_function_stdarg)
+    data->named_arg = 1;  /* No varadic parms.  */
+  else if (TREE_CHAIN (parm))
+    data->named_arg = 1;  /* Not the last non-varadic parm. */
+  else if (targetm.calls.strict_argument_naming (&all->args_so_far))
+    data->named_arg = 1;  /* Only varadic ones are unnamed.  */
   else
-    data->named_arg = !data->last_named;
+    data->named_arg = 0;  /* Treat as varadic.  */
 
   nominal_type = TREE_TYPE (parm);
   passed_type = DECL_ARG_TYPE (parm);
@@ -3055,7 +3045,6 @@ assign_parms (tree fndecl)
   struct assign_parm_data_all all;
   tree fnargs, parm;
   rtx internal_arg_pointer;
-  int varargs_setup = 0;
 
   /* If the reg that the virtual arg pointer will be translated into is
      not a fixed reg or is the stack pointer, make a copy of the virtual
@@ -3090,16 +3079,8 @@ assign_parms (tree fndecl)
          continue;
        }
 
-      /* Handle stdargs.  LAST_NAMED is a slight mis-nomer; it's also true
-        for the unnamed dummy argument following the last named argument.
-        See ABI silliness wrt strict_argument_naming and NAMED_ARG.  So
-        we only want to do this when we get to the actual last named
-        argument, which will be the first time LAST_NAMED gets set.  */
-      if (data.last_named && !varargs_setup)
-       {
-         varargs_setup = true;
-         assign_parms_setup_varargs (&all, &data, false);
-       }
+      if (current_function_stdarg && !TREE_CHAIN (parm))
+       assign_parms_setup_varargs (&all, &data, false);
 
       /* Find out where the parameter arrives in this function.  */
       assign_parm_find_entry_rtl (&all, &data);
index be5388f72a863f9545bee7049e7a94089c7412d8..8454c08cc60db248b839db05f98219311f4ca26d 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-10  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/20375
+       * g++.dg/other/stdarg3.C: New.
+
 2005-03-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/18384, c++/18327
diff --git a/gcc/testsuite/g++.dg/other/stdarg3.C b/gcc/testsuite/g++.dg/other/stdarg3.C
new file mode 100644 (file)
index 0000000..3d11dff
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 8 Mar 2005 <nathan@codesourcery.com>
+
+// PR 20375: ICE
+// Origin: Joseph S. Myers <jsm28@gcc.gnu.org>
+// { dg-options "-mlp64" { target "ia64-*-*" } }
+
+union U
+{
+  void *m[7];
+};
+
+struct C;
+
+void f(struct C *c, float f, union U, ...)
+{ }