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]

[lto] cp/*.c: Use copy_type_arg_types_skip.


Hi,

Tested on x86_64-pc-linux-gnu.  Committed to the LTO branch as
obvious.

Kazu Hirata

2006-08-09  Kazu Hirata  <kazu@codesourcery.com>

	* call.c (standard_conversion): Use copy_type_arg_types_skip.
	* class.c (build_clone,
	resolve_address_of_overloaded_function): Likewise.
	* decl.c (revert_static_member_fn): Likewise.
	* decl2.c (build_memfn_type): Likewise.
	* pt.c (tsubst_function_type, unify): Likewise.
	* rtti.c (get_tinfo_decl): Likewise.
	* typeck.c (merge_types): Likewise.

Index: cp/call.c
===================================================================
--- cp/call.c	(revision 116014)
+++ cp/call.c	(working copy)
@@ -775,6 +775,7 @@ standard_conversion (tree to, tree from,
       tree tofn = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (to));
       tree fbase = TREE_TYPE (nth_parm_type (TYPE_ARG_TYPES (fromfn), 0));
       tree tbase = TREE_TYPE (nth_parm_type (TYPE_ARG_TYPES (tofn), 0));
+      tree parm_types;
 
       if (!DERIVED_FROM_P (fbase, tbase)
 	  || !same_type_p (TREE_TYPE (fromfn), TREE_TYPE (tofn))
@@ -784,9 +785,9 @@ standard_conversion (tree to, tree from,
 	return NULL;
 
       from = cp_build_qualified_type (tbase, cp_type_quals (fbase));
+      parm_types = copy_type_arg_types_skip (TYPE_ARG_TYPES (fromfn), 1);
       from = build_method_type_directly (from,
-					 TREE_TYPE (fromfn),
-					 TREE_CHAIN (TYPE_ARG_TYPES (fromfn)));
+					 TREE_TYPE (fromfn), parm_types);
       from = build_ptrmemfunc_type (build_pointer_type (from));
       conv = build_conv (ck_pmem, from, conv);
       conv->base_p = true;
Index: cp/class.c
===================================================================
--- cp/class.c	(revision 116014)
+++ cp/class.c	(working copy)
@@ -3754,18 +3754,20 @@ build_clone (tree fn, tree name)
       tree basetype;
       tree parmtypes;
       tree exceptions;
+      int skip = 0;
 
       exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (clone));
       basetype = TYPE_METHOD_BASETYPE (TREE_TYPE (clone));
       parmtypes = TYPE_ARG_TYPES (TREE_TYPE (clone));
       /* Skip the `this' parameter.  */
-      parmtypes = TREE_CHAIN (parmtypes);
+      skip++;
       /* Skip the in-charge parameter.  */
-      parmtypes = TREE_CHAIN (parmtypes);
+      skip++;
       /* And the VTT parm, in a complete [cd]tor.  */
       if (DECL_HAS_VTT_PARM_P (fn)
 	  && ! DECL_NEEDS_VTT_PARM_P (clone))
-	parmtypes = TREE_CHAIN (parmtypes);
+	skip++;
+      parmtypes = copy_type_arg_types_skip (parmtypes, skip);
        /* If this is subobject constructor or destructor, add the vtt
 	 parameter.  */
       TREE_TYPE (clone)
@@ -5755,7 +5757,7 @@ resolve_address_of_overloaded_function (
 
       /* Never do unification on the 'this' parameter.  */
       if (TREE_CODE (target_fn_type) == METHOD_TYPE)
-	target_arg_types = TREE_CHAIN (target_arg_types);
+	target_arg_types = copy_type_arg_types_skip (target_arg_types, 1);
 
       for (fns = overload; fns; fns = OVL_NEXT (fns))
 	{
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 116014)
+++ cp/decl.c	(working copy)
@@ -11450,11 +11450,11 @@ revert_static_member_fn (tree decl)
   tree function = TREE_TYPE (decl);
   tree args = TYPE_ARG_TYPES (function);
 
-  if (cp_type_quals (TREE_TYPE (TREE_VALUE (args)))
+  if (cp_type_quals (TREE_TYPE (nth_parm_type (args, 0)))
       != TYPE_UNQUALIFIED)
     error ("static member function %q#D declared with type qualifiers", decl);
 
-  args = TREE_CHAIN (args);
+  args = copy_type_arg_types_skip (args, 1);
   tmp = build_function_type (TREE_TYPE (function), args);
   tmp = build_qualified_type (tmp, cp_type_quals (function));
   tmp = build_exception_variant (tmp,
Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 116014)
+++ cp/decl2.c	(working copy)
@@ -113,16 +113,18 @@ build_memfn_type (tree fntype, tree ctyp
 {
   tree raises;
   int type_quals;
+  tree parm_types;
 
   if (fntype == error_mark_node || ctype == error_mark_node)
     return error_mark_node;
 
   type_quals = quals & ~TYPE_QUAL_RESTRICT;
   ctype = cp_build_qualified_type (ctype, type_quals);
-  fntype = build_method_type_directly (ctype, TREE_TYPE (fntype),
-				       (TREE_CODE (fntype) == METHOD_TYPE
-					? TREE_CHAIN (TYPE_ARG_TYPES (fntype))
-					: TYPE_ARG_TYPES (fntype)));
+  if (TREE_CODE (fntype) == METHOD_TYPE)
+    parm_types = copy_type_arg_types_skip (TYPE_ARG_TYPES (fntype), 1);
+  else
+    parm_types = TYPE_ARG_TYPES (fntype);
+  fntype = build_method_type_directly (ctype, TREE_TYPE (fntype), parm_types);
   raises = TYPE_RAISES_EXCEPTIONS (fntype);
   if (raises)
     fntype = build_exception_variant (fntype, raises);
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 116014)
+++ cp/pt.c	(working copy)
@@ -6813,7 +6813,9 @@ tsubst_function_type (tree t,
     fntype = build_function_type (return_type, arg_types);
   else
     {
-      tree r = TREE_TYPE (TREE_VALUE (arg_types));
+      tree r = TREE_TYPE (nth_parm_type (arg_types, 0));
+      tree new_parm_types;
+
       if (! IS_AGGR_TYPE (r))
 	{
 	  /* [temp.deduct]
@@ -6829,8 +6831,8 @@ tsubst_function_type (tree t,
 	  return error_mark_node;
 	}
 
-      fntype = build_method_type_directly (r, return_type,
-					   TREE_CHAIN (arg_types));
+      new_parm_types = copy_type_arg_types_skip (arg_types, 1);
+      fntype = build_method_type_directly (r, return_type, new_parm_types);
     }
   fntype = cp_build_qualified_type_real (fntype, TYPE_QUALS (t), complain);
   fntype = cp_build_type_attribute_variant (fntype, TYPE_ATTRIBUTES (t));
@@ -10485,6 +10487,7 @@ unify (tree tparms, tree targs, tree par
 	{
 	  tree method_type;
 	  tree fntype;
+	  tree new_parm_types;
 	  cp_cv_quals cv_quals;
 
 	  /* Check top-level cv qualifiers */
@@ -10497,9 +10500,8 @@ unify (tree tparms, tree targs, tree par
 
 	  /* Determine the type of the function we are unifying against. */
 	  method_type = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (arg));
-	  fntype =
-	    build_function_type (TREE_TYPE (method_type),
-				 TREE_CHAIN (TYPE_ARG_TYPES (method_type)));
+	  new_parm_types = copy_type_arg_types_skip (TYPE_ARG_TYPES (method_type), 1);
+	  fntype = build_function_type (TREE_TYPE (method_type), new_parm_types);
 
 	  /* Extract the cv-qualifiers of the member function from the
 	     implicit object parameter and place them on the function
Index: cp/rtti.c
===================================================================
--- cp/rtti.c	(revision 116014)
+++ cp/rtti.c	(working copy)
@@ -352,8 +352,10 @@ get_tinfo_decl (tree type)
     }
 
   if (TREE_CODE (type) == METHOD_TYPE)
-    type = build_function_type (TREE_TYPE (type),
-				TREE_CHAIN (TYPE_ARG_TYPES (type)));
+    {
+      tree tmp = copy_type_arg_types_skip (TYPE_ARG_TYPES (type), 1);
+      type = build_function_type (TREE_TYPE (type), tmp);
+    }
 
   /* For a class type, the variable is cached in the type node
      itself.  */
Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 116014)
+++ cp/typeck.c	(working copy)
@@ -678,14 +678,15 @@ merge_types (tree t1, tree t2)
 	tree basetype = TREE_TYPE (nth_parm_type (TYPE_ARG_TYPES (t2), 0));
 	tree raises = TYPE_RAISES_EXCEPTIONS (t1);
 	tree t3;
+	tree t;
 
 	/* If this was a member function type, get back to the
 	   original type of type member function (i.e., without
 	   the class instance variable up front.  */
-	t1 = build_function_type (TREE_TYPE (t1),
-				  TREE_CHAIN (TYPE_ARG_TYPES (t1)));
-	t2 = build_function_type (TREE_TYPE (t2),
-				  TREE_CHAIN (TYPE_ARG_TYPES (t2)));
+	t = copy_type_arg_types_skip (TYPE_ARG_TYPES (t1), 1);
+	t1 = build_function_type (TREE_TYPE (t1), t);
+	t = copy_type_arg_types_skip (TYPE_ARG_TYPES (t2), 1);
+	t2 = build_function_type (TREE_TYPE (t2), t);
 	t3 = merge_types (t1, t2);
 	t3 = build_method_type_directly (basetype, TREE_TYPE (t3),
 					 TYPE_ARG_TYPES (t3));


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