From 930672adb7c3ae012e0af46eb19b0e8de1974cfb Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 15 Mar 2011 13:39:28 +0000 Subject: [PATCH] re PR middle-end/47650 (wrong output of print_generic_decl() called from a plugin) 2011-03-15 Richard Guenther 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. From-SVN: r170995 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 7 +++++++ .../gfortran.dg/c_f_pointer_tests_3.f90 | 2 +- gcc/testsuite/gfortran.dg/ishft_4.f90 | 4 ++-- gcc/testsuite/gfortran.dg/leadz_trailz_3.f90 | 2 +- gcc/tree-pretty-print.c | 20 +++++++++++-------- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dc5f897ca74..d3f2eeffb7a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-03-15 Richard Guenther + + PR middle-end/47650 + * tree-pretty-print.c (dump_function_declaration): Properly + dump unprototyped and varargs function types. + 2011-03-15 Richard Guenther PR tree-optimization/13954 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0257a77908d..753f90045b6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-03-15 Richard Guenther + + PR middle-end/47650 + * gfortran.dg/c_f_pointer_tests_3.f90: Adjust. + * gfortran.dg/ishft_4.f90: Likewise. + * gfortran.dg/leadz_trailz_3.f90: Likewise. + 2011-03-15 Richard Guenther PR tree-optimization/13954 diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_tests_3.f90 b/gcc/testsuite/gfortran.dg/c_f_pointer_tests_3.f90 index 3b28f52b4e7..f7d6fa78eb4 100644 --- a/gcc/testsuite/gfortran.dg/c_f_pointer_tests_3.f90 +++ b/gcc/testsuite/gfortran.dg/c_f_pointer_tests_3.f90 @@ -30,6 +30,6 @@ end program test ! { 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 { scan-tree-dump-times " fprocptr = .integer.kind=4. .\\*<.*>. ... cfunptr;" 1 "original" } } ! ! { dg-final { cleanup-tree-dump "original" } } diff --git a/gcc/testsuite/gfortran.dg/ishft_4.f90 b/gcc/testsuite/gfortran.dg/ishft_4.f90 index 4e2ad2b137f..0315c7feb91 100644 --- a/gcc/testsuite/gfortran.dg/ishft_4.f90 +++ b/gcc/testsuite/gfortran.dg/ishft_4.f90 @@ -35,6 +35,6 @@ end program ! -- 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 { scan-tree-dump-times "foo *\\\(\\\)" 6 "original" } } +! { dg-final { scan-tree-dump-times "bar *\\\(\\\)" 6 "original" } } ! { dg-final { cleanup-tree-dump "original" } } diff --git a/gcc/testsuite/gfortran.dg/leadz_trailz_3.f90 b/gcc/testsuite/gfortran.dg/leadz_trailz_3.f90 index b54a11f63da..f8466ffb95d 100644 --- a/gcc/testsuite/gfortran.dg/leadz_trailz_3.f90 +++ b/gcc/testsuite/gfortran.dg/leadz_trailz_3.f90 @@ -26,5 +26,5 @@ end program ! -- 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 { scan-tree-dump-times "foo *\\\(\\\)" 8 "original" } } ! { dg-final { cleanup-tree-dump "original" } } 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, ')'); } -- 2.30.2