From d700b485013307105444926a807a33e1a9b2a413 Mon Sep 17 00:00:00 2001 From: kenner Date: Mon, 28 Jun 2004 12:08:20 +0000 Subject: [PATCH] * tree-pretty-print.c (dump_function_declaration): New. (dump_generic_node, case FUNCTION_TYPE): Call it. (dump_generic_node, case RECORD_TYPE): Don't output dup semicolon. (dump_generic_node, case DECL_EXPR): New case. (dump_generic_node, case PLACEHOLDER_EXPR): Handle. (print_declaration): Handle type and function declarations. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83782 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 ++++ gcc/tree-pretty-print.c | 89 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 66 insertions(+), 30 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f011e27b8dd..a102ca073cc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2004-06-28 Richard Kenner + * tree-pretty-print.c (dump_function_declaration): New. + (dump_generic_node, case FUNCTION_TYPE): Call it. + (dump_generic_node, case RECORD_TYPE): Don't output dup semicolon. + (dump_generic_node, case DECL_EXPR): New case. + (dump_generic_node, case PLACEHOLDER_EXPR): Handle. + (print_declaration): Handle type and function declarations. + * tree-nested.c (create_tmp_var_for): Allow ARRAY_TYPE. (convert_nonlocal_reference, convert_local_reference): Properly convert nest of handled component references. diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 5fe5a4f677a..9eb478caaac 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -168,6 +168,40 @@ dump_decl_name (pretty_printer *buffer, tree node, int flags) } } +/* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and + FLAGS are as in dump_generic_node. */ + +static void +dump_function_declaration (pretty_printer *buffer, tree node, + int spc, int flags) +{ + bool wrote_arg = false; + tree arg; + + 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, ')'); +} + /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree.h). If IS_STMT is true, the object printed is considered to be a statement @@ -179,7 +213,7 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, { tree type; tree op0, op1; - const char* str; + const char *str; bool is_expr; if (node == NULL_TREE) @@ -296,6 +330,7 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE) { tree fnode = TREE_TYPE (node); + dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false); pp_space (buffer); pp_character (buffer, '('); @@ -306,24 +341,7 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, pp_printf (buffer, "", TYPE_UID (node)); pp_character (buffer, ')'); - pp_space (buffer); - pp_character (buffer, '('); - /* Print the argument types. The last element in the list is a - VOID_TYPE. The following avoid to print the last element. */ - { - tree tmp = TYPE_ARG_TYPES (fnode); - while (tmp && TREE_CHAIN (tmp) && tmp != error_mark_node) - { - dump_generic_node (buffer, TREE_VALUE (tmp), spc, flags, false); - tmp = TREE_CHAIN (tmp); - if (TREE_CHAIN (tmp) && TREE_CODE (TREE_CHAIN (tmp)) == TREE_LIST) - { - pp_character (buffer, ','); - pp_space (buffer); - } - } - } - pp_character (buffer, ')'); + dump_function_declaration (buffer, fnode, spc, flags); } else { @@ -544,9 +562,7 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, break; } if (DECL_NAME (node)) - { - dump_decl_name (buffer, node, flags); - } + dump_decl_name (buffer, node, flags); else { if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE @@ -560,10 +576,10 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, } else { - pp_string (buffer, "struct "); + pp_string (buffer, + (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE + ? "union" : "struct ")); dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false); - pp_character (buffer, ';'); - pp_newline (buffer); } } break; @@ -766,6 +782,11 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, pp_character (buffer, '>'); break; + case DECL_EXPR: + print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags); + is_stmt = false; + break; + case COND_EXPR: if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node) { @@ -884,7 +905,9 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, break; case PLACEHOLDER_EXPR: - NIY; + pp_string (buffer, "'); break; /* Binary arithmetic and logic expressions. */ @@ -1423,12 +1446,11 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, static void print_declaration (pretty_printer *buffer, tree t, int spc, int flags) { - /* Don't print type declarations. */ - if (TREE_CODE (t) == TYPE_DECL) - return; - INDENT (spc); + if (TREE_CODE (t) == TYPE_DECL) + pp_string (buffer, "typedef "); + if (DECL_REGISTER (t)) pp_string (buffer, "register "); @@ -1471,6 +1493,13 @@ print_declaration (pretty_printer *buffer, tree t, int spc, int flags) tmp = TREE_TYPE (tmp); } } + else if (TREE_CODE (t) == FUNCTION_DECL) + { + dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false); + pp_space (buffer); + dump_decl_name (buffer, t, flags); + dump_function_declaration (buffer, TREE_TYPE (t), spc, flags); + } else { /* Print type declaration. */ -- 2.11.0