aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-pretty-print.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-03-15 13:39:28 +0000
committerRichard Guenther <rguenther@suse.de>2011-03-15 13:39:28 +0000
commitfc652e6bb9d405b2304d4e7c088e43aa90c97692 (patch)
tree21dbe136eadd04262c13f6f277122dfec08e0839 /gcc/tree-pretty-print.c
parentf1d6b0d42f5a90ec5caa2fcc1a7aef5ee71ee7b9 (diff)
2011-03-15 Richard Guenther <rguenther@suse.de>
PR middle-end/47650 * tree-pretty-print.c (dump_function_declaration): Properly dump unprototyped and varargs function types. * gfortran.dg/c_f_pointer_tests_3.f90: Adjust. * gfortran.dg/ishft_4.f90: Likewise. * gfortran.dg/leadz_trailz_3.f90: Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@170995 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-pretty-print.c')
-rw-r--r--gcc/tree-pretty-print.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 12ef38817eb..f2f5a220018 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -232,23 +232,27 @@ dump_function_declaration (pretty_printer *buffer, tree node,
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. */
+ /* Print the argument types. */
arg = TYPE_ARG_TYPES (node);
- while (arg && TREE_CHAIN (arg) && arg != error_mark_node)
+ while (arg && arg != void_list_node && 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)
+ 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);
}
- if (!wrote_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, ')');
}