This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] Use num_parm_types and its friends in grokparms.
- From: Kazu Hirata <kazu at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: sandra at codesourcery dot com, joseph at codesourcery dot com
- Date: Tue, 1 Aug 2006 22:51:59 -0700
- Subject: [lto] Use num_parm_types and its friends in grokparms.
Hi,
Attached is a patch to use num_parm_types and its friends in
grokparms.
This patch is a little different from other patches to introduce uses
of num_parm_types. Without a patch to convert TYPE_ARG_TYPES to use
TREE_VEC in near future, TYPE_ARG_TYPES and DECL_ARGUMENTS use the
same representation, namely TREE_LIST. However, with such a patch,
TYPE_ARG_TYPES and DECL_ARGUMENTS use different representations. This
difference makes it necessary to convert between the two when we
process a old-style parameter declaration.
Sandra, you probably want to change the way I build arg_info->parms,
which is later copied to DECL_ARGUMENTS. I hope you don't mind me
leaving it up to you.
Tested on x86_64-pc-linux-gnu. OK to apply to the LTO branch?
Kazu Hirata
2006-08-02 Kazu Hirata <kazu@codesourcery.com>
* c-decl.c (grokparms): Use num_parm_types and its friends.
Convert arg_info->types to arg_info->parms.
Index: c-decl.c
===================================================================
--- c-decl.c (revision 115853)
+++ c-decl.c (working copy)
@@ -4862,18 +4862,28 @@ grokparms (struct c_arg_info *arg_info,
if (arg_types == error_mark_node)
return 0; /* don't set TYPE_ARG_TYPES in this case */
- else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE)
+ else if (arg_types
+ && TREE_CODE (nth_parm_type (arg_types, 0)) == IDENTIFIER_NODE)
{
+ tree t = NULL, *p = &t;
+ int len = num_parm_types (arg_types);
+ int i;
+
if (!funcdef_flag)
pedwarn ("parameter names (without types) in function declaration");
- arg_info->parms = arg_info->types;
+ for (i = 0; i < len; i++)
+ {
+ *p = build_tree_list (NULL_TREE, nth_parm_type (arg_types, i));
+ p = &TREE_CHAIN (*p);
+ }
+ arg_info->parms = t;
arg_info->types = 0;
return 0;
}
else
{
- tree parm, type, typelt;
+ tree parm, type;
unsigned int parmno;
/* If there is a parameter of incomplete type in a definition,
@@ -4885,11 +4895,11 @@ grokparms (struct c_arg_info *arg_info,
however the function cannot be defined or called, so
warn. */
- for (parm = arg_info->parms, typelt = arg_types, parmno = 1;
+ for (parm = arg_info->parms, parmno = 0;
parm;
- parm = TREE_CHAIN (parm), typelt = TREE_CHAIN (typelt), parmno++)
+ parm = TREE_CHAIN (parm), parmno++)
{
- type = TREE_VALUE (typelt);
+ type = nth_parm_type (arg_types, parmno);
if (type == error_mark_node)
continue;
@@ -4899,19 +4909,19 @@ grokparms (struct c_arg_info *arg_info,
{
if (DECL_NAME (parm))
error ("parameter %u (%q+D) has incomplete type",
- parmno, parm);
+ parmno + 1, parm);
else
error ("%Jparameter %u has incomplete type",
- parm, parmno);
+ parm, parmno + 1);
- TREE_VALUE (typelt) = error_mark_node;
+ *(nth_parm_type_ptr (arg_types, parmno)) = error_mark_node;
TREE_TYPE (parm) = error_mark_node;
}
else if (VOID_TYPE_P (type))
{
if (DECL_NAME (parm))
warning (0, "parameter %u (%q+D) has void type",
- parmno, parm);
+ parmno + 1, parm);
else
warning (0, "%Jparameter %u has void type",
parm, parmno);