tree-pretty-print.c (dump_function_declaration): New.

* 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.

From-SVN: r83782
This commit is contained in:
Richard Kenner 2004-06-28 12:08:20 +00:00 committed by Richard Kenner
parent 70883f7262
commit 5f2dcbe1ff
2 changed files with 66 additions and 30 deletions

View File

@ -1,5 +1,12 @@
2004-06-28 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* 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.

View File

@ -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, "<T%x>", 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, "<PLACEHOLDER_EXPR ");
dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
pp_character (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. */