This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] Do not use recursion in tsubst_arg_types.
- From: Kazu Hirata <kazu at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: mark at codesourcery dot com
- Date: Wed, 26 Jul 2006 23:40:07 -0700
- Subject: [lto] Do not use recursion in tsubst_arg_types.
Hi,
Attached is a patch to not to use recursion in tsubst_arg_types.
We would eventually like to use TREE_VEC for TYPE_ARG_TYPES. The
recursive nature of tsubst_arg_types makes it difficult to convert the
function to support TREE_VEC in TYPE_ARG_TYPES.
The patch removes recursion from the function. The patch does not
introduce uses of nth_parm_type and its friends for simplicity.
Tested on x86_64-pc-linux-gnu. OK to apply to the LTO branch?
Kazu Hirata
2006-07-27 Kazu Hirata <kazu@codesourcery.com>
* pt.c (tsubst_arg_types): Do not use recursion.
Index: cp/pt.c
===================================================================
*** cp/pt.c (revision 115760)
--- cp/pt.c (working copy)
*************** tsubst_arg_types (tree arg_types,
*** 6713,6749 ****
tsubst_flags_t complain,
tree in_decl)
{
! tree remaining_arg_types;
! tree type;
tree result = NULL_TREE;
! if (!arg_types || arg_types == void_list_node)
! return arg_types;
! remaining_arg_types = tsubst_arg_types (TREE_CHAIN (arg_types),
! args, complain, in_decl);
! if (remaining_arg_types == error_mark_node)
! return error_mark_node;
! type = tsubst (TREE_VALUE (arg_types), args, complain, in_decl);
! if (type == error_mark_node)
! return error_mark_node;
! if (VOID_TYPE_P (type))
! {
! if (complain & tf_error)
{
! error ("invalid parameter type %qT", type);
! if (in_decl)
! error ("in declaration %q+D", in_decl);
}
- return error_mark_node;
- }
! /* Do array-to-pointer, function-to-pointer conversion, and ignore
! top-level qualifiers as required. */
! type = TYPE_MAIN_VARIANT (type_decays_to (type));
! result = hash_tree_cons (NULL_TREE, type, remaining_arg_types);
return result;
}
--- 6713,6752 ----
tsubst_flags_t complain,
tree in_decl)
{
! int len = num_parm_types (arg_types);
! int i;
tree result = NULL_TREE;
! for (i = len - 1; i >= 0; i--)
! {
! tree type = nth_parm_type (arg_types, i);
! if (i == len - 1 && type == void_type_node)
! {
! result = void_list_node;
! continue;
! }
! type = tsubst (type, args, complain, in_decl);
! if (type == error_mark_node)
! return error_mark_node;
! if (VOID_TYPE_P (type))
{
! if (complain & tf_error)
! {
! error ("invalid parameter type %qT", type);
! if (in_decl)
! error ("in declaration %q+D", in_decl);
! }
! return error_mark_node;
}
! /* Do array-to-pointer, function-to-pointer conversion, and
! ignore top-level qualifiers as required. */
! type = TYPE_MAIN_VARIANT (type_decays_to (type));
! result = hash_tree_cons (NULL_TREE, type, result);
! }
return result;
}