This fixes PR47650, bogus function type dumping for unprototyped and variadic functions.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2011-03-15 Richard Guenther <rguent...@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. Index: gcc/tree-pretty-print.c =================================================================== *** gcc/tree-pretty-print.c.orig 2011-03-15 13:52:36.000000000 +0100 --- gcc/tree-pretty-print.c 2011-03-15 14:04:05.000000000 +0100 *************** 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, ')'); } Index: gcc/testsuite/gfortran.dg/c_f_pointer_tests_3.f90 =================================================================== *** gcc/testsuite/gfortran.dg/c_f_pointer_tests_3.f90.orig 2008-07-03 10:16:03.000000000 +0200 --- gcc/testsuite/gfortran.dg/c_f_pointer_tests_3.f90 2011-03-15 14:08:16.000000000 +0100 *************** end program test *** 30,35 **** ! { dg-final { scan-tree-dump-times " fptr = .integer.kind=4. .. cptr" 1 "original" } } ! ! Check c_f_procpointer ! ! { dg-final { scan-tree-dump-times " fprocptr = .integer.kind=4. .\\*<.*>. .void.. cfunptr;" 1 "original" } } ! ! { dg-final { cleanup-tree-dump "original" } } --- 30,35 ---- ! { dg-final { scan-tree-dump-times " fptr = .integer.kind=4. .. cptr" 1 "original" } } ! ! Check c_f_procpointer ! ! { dg-final { scan-tree-dump-times " fprocptr = .integer.kind=4. .\\*<.*>. ... cfunptr;" 1 "original" } } ! ! { dg-final { cleanup-tree-dump "original" } } Index: gcc/testsuite/gfortran.dg/ishft_4.f90 =================================================================== *** gcc/testsuite/gfortran.dg/ishft_4.f90.orig 2010-09-03 10:28:48.000000000 +0200 --- gcc/testsuite/gfortran.dg/ishft_4.f90 2011-03-15 14:35:01.000000000 +0100 *************** end program *** 35,40 **** ! -- once in the function definition itself ! -- plus as many times as the function is called ! ! ! { dg-final { scan-tree-dump-times "foo *\\\(\\\)" 5 "original" } } ! ! { dg-final { scan-tree-dump-times "bar *\\\(\\\)" 5 "original" } } ! { dg-final { cleanup-tree-dump "original" } } --- 35,40 ---- ! -- once in the function definition itself ! -- plus as many times as the function is called ! ! ! { dg-final { scan-tree-dump-times "foo *\\\(\\\)" 6 "original" } } ! ! { dg-final { scan-tree-dump-times "bar *\\\(\\\)" 6 "original" } } ! { dg-final { cleanup-tree-dump "original" } } Index: gcc/testsuite/gfortran.dg/leadz_trailz_3.f90 =================================================================== *** gcc/testsuite/gfortran.dg/leadz_trailz_3.f90.orig 2010-09-10 11:48:44.000000000 +0200 --- gcc/testsuite/gfortran.dg/leadz_trailz_3.f90 2011-03-15 14:34:39.000000000 +0100 *************** end program *** 26,30 **** ! -- once in the function definition itself ! -- plus as many times as the function is called ! ! ! { dg-final { scan-tree-dump-times "foo *\\\(\\\)" 7 "original" } } ! { dg-final { cleanup-tree-dump "original" } } --- 26,30 ---- ! -- once in the function definition itself ! -- plus as many times as the function is called ! ! ! { dg-final { scan-tree-dump-times "foo *\\\(\\\)" 8 "original" } } ! { dg-final { cleanup-tree-dump "original" } }