}
}
+/* 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
{
tree type;
tree op0, op1;
- const char* str;
+ const char *str;
bool is_expr;
if (node == NULL_TREE)
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, '(');
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
{
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
}
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;
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)
{
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. */
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 ");
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. */