This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Dump function return type, properly dump unprototyped and vararg types
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: fortran at gcc dot gnu dot org
- Date: Fri, 14 Jan 2011 13:58:17 +0100 (CET)
- Subject: [PATCH] Dump function return type, properly dump unprototyped and vararg types
This adjusts dumping to be more helpful (and less bogus) in the face
of variable argument function types and unprototyped function types
(which helped debugging PR47281 a lot).
ISTR loads of fortran testcases that have exact function type dump
scannings, so I'm conditionalizing applying this on that I'm wrong ;)
Richard.
2011-01-14 Richard Guenther <rguenther@suse.de>
* tree-cfg.c (dump_function_to_file): Dump the function return type.
* tree-pretty-print.c (dump_function_declaration): Properly
dump unprototyped and varargs function types.
Index: gcc/tree-cfg.c
===================================================================
*** gcc/tree-cfg.c (revision 168780)
--- gcc/tree-cfg.c (working copy)
*************** dump_function_to_file (tree fn, FILE *fi
*** 6356,6362 ****
basic_block bb;
tree chain;
! fprintf (file, "%s (", lang_hooks.decl_printable_name (fn, 2));
arg = DECL_ARGUMENTS (fn);
while (arg)
--- 6429,6436 ----
basic_block bb;
tree chain;
! print_generic_expr (file, TREE_TYPE (TREE_TYPE (fn)), dump_flags);
! fprintf (file, "\n%s (", lang_hooks.decl_printable_name (fn, 2));
arg = DECL_ARGUMENTS (fn);
while (arg)
Index: gcc/tree-pretty-print.c
===================================================================
*** gcc/tree-pretty-print.c (revision 168780)
--- gcc/tree-pretty-print.c (working copy)
*************** dump_function_declaration (pretty_printe
*** 232,254 ****
pp_space (buffer);
pp_character (buffer, '(');
! /* Print the argument types. The last element in the list is a VOID_TYPE.
! The following avoids printing the last element. */
arg = TYPE_ARG_TYPES (node);
! while (arg && TREE_CHAIN (arg) && arg != error_mark_node)
{
! wrote_arg = true;
! dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
! arg = TREE_CHAIN (arg);
! if (TREE_CHAIN (arg) && TREE_CODE (TREE_CHAIN (arg)) == TREE_LIST)
{
pp_character (buffer, ',');
pp_space (buffer);
}
}
! if (!wrote_arg)
pp_string (buffer, "void");
pp_character (buffer, ')');
}
--- 232,258 ----
pp_space (buffer);
pp_character (buffer, '(');
! /* Print the argument types. */
arg = TYPE_ARG_TYPES (node);
! while (arg && arg != void_list_node && arg != error_mark_node)
{
! if (wrote_arg)
{
pp_character (buffer, ',');
pp_space (buffer);
}
+ wrote_arg = true;
+ dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
+ arg = TREE_CHAIN (arg);
}
! /* Drop the trailing void_type_node if we had any previous argument. */
! if (arg == void_list_node && !wrote_arg)
pp_string (buffer, "void");
+ /* Properly dump vararg function types. */
+ else if (!arg && wrote_arg)
+ pp_string (buffer, ", ...");
+ /* Avoid printing any arg for unprototyped functions. */
pp_character (buffer, ')');
}