Commit 3c1ab1ab by Gabriel Dos Reis Committed by Gabriel Dos Reis

error.c (dump_scope): Add a cxx_pretty_printer parameter.

	* error.c (dump_scope): Add a cxx_pretty_printer parameter.
	Adjust callers.
	(dump_template_argument): Likewise.
	(dump_template_argument_list): Likewise.
	(dump_template_parameter): Likewise.
	(dump_template_bindings): Likewise.
	(dump_alias_template_specialization): Likewise.
	(dump_type): Likewise.
	(dump_typename): Likewise.
	(dump_aggr_type): Likewise.
	(dump_type_prefix): Likewise.
	(dump_type_suffix): Likewise.
	(dump_global_iord): Likewise.
	(dump_simple_decl): Likewise.
	(dump_decl): Likewise.
	(dump_template_decl): Likewise.
	(dump_function_decl): Likewise.
	(dump_parameters): Likewise.
	(dump_ref_qualifier): Likewise.
	(dump_exception_spec): Likewise.
	(dump_function_name): Likewise.
	(dump_template_parms): Likewise.
	(dump_call_expr_args): Likewise.
	(dump_aggr_init_expr_args): Likewise.
	(dump_expr_list): Likewise.
	(dump_expr_init_vec): Likewise.
	(dump_expr): Likewise.
	(dump_binary_op): Likewise.
	(dump_unary_op): Likewise.

From-SVN: r201818
parent 5945bebf
2013-08-17 Gabriel Dos Reis <gdr@integrable-solutions.net>
* error.c (dump_scope): Add a cxx_pretty_printer parameter.
Adjust callers.
(dump_template_argument): Likewise.
(dump_template_argument_list): Likewise.
(dump_template_parameter): Likewise.
(dump_template_bindings): Likewise.
(dump_alias_template_specialization): Likewise.
(dump_type): Likewise.
(dump_typename): Likewise.
(dump_aggr_type): Likewise.
(dump_type_prefix): Likewise.
(dump_type_suffix): Likewise.
(dump_global_iord): Likewise.
(dump_simple_decl): Likewise.
(dump_decl): Likewise.
(dump_template_decl): Likewise.
(dump_function_decl): Likewise.
(dump_parameters): Likewise.
(dump_ref_qualifier): Likewise.
(dump_exception_spec): Likewise.
(dump_function_name): Likewise.
(dump_template_parms): Likewise.
(dump_call_expr_args): Likewise.
(dump_aggr_init_expr_args): Likewise.
(dump_expr_list): Likewise.
(dump_expr_init_vec): Likewise.
(dump_expr): Likewise.
(dump_binary_op): Likewise.
(dump_unary_op): Likewise.
2013-08-14 Paolo Carlini <paolo.carlini@oracle.com> 2013-08-14 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51912 PR c++/51912
......
...@@ -59,33 +59,34 @@ static const char *op_to_string (enum tree_code); ...@@ -59,33 +59,34 @@ static const char *op_to_string (enum tree_code);
static const char *parm_to_string (int); static const char *parm_to_string (int);
static const char *type_to_string (tree, int); static const char *type_to_string (tree, int);
static void dump_alias_template_specialization (tree, int); static void dump_alias_template_specialization (cxx_pretty_printer *, tree, int);
static void dump_type (tree, int); static void dump_type (cxx_pretty_printer *, tree, int);
static void dump_typename (tree, int); static void dump_typename (cxx_pretty_printer *, tree, int);
static void dump_simple_decl (tree, tree, int); static void dump_simple_decl (cxx_pretty_printer *, tree, tree, int);
static void dump_decl (tree, int); static void dump_decl (cxx_pretty_printer *, tree, int);
static void dump_template_decl (tree, int); static void dump_template_decl (cxx_pretty_printer *, tree, int);
static void dump_function_decl (tree, int); static void dump_function_decl (cxx_pretty_printer *, tree, int);
static void dump_expr (tree, int); static void dump_expr (cxx_pretty_printer *, tree, int);
static void dump_unary_op (const char *, tree, int); static void dump_unary_op (cxx_pretty_printer *, const char *, tree, int);
static void dump_binary_op (const char *, tree, int); static void dump_binary_op (cxx_pretty_printer *, const char *, tree, int);
static void dump_aggr_type (tree, int); static void dump_aggr_type (cxx_pretty_printer *, tree, int);
static void dump_type_prefix (tree, int); static void dump_type_prefix (cxx_pretty_printer *, tree, int);
static void dump_type_suffix (tree, int); static void dump_type_suffix (cxx_pretty_printer *, tree, int);
static void dump_function_name (tree, int); static void dump_function_name (cxx_pretty_printer *, tree, int);
static void dump_call_expr_args (tree, int, bool); static void dump_call_expr_args (cxx_pretty_printer *, tree, int, bool);
static void dump_aggr_init_expr_args (tree, int, bool); static void dump_aggr_init_expr_args (cxx_pretty_printer *, tree, int, bool);
static void dump_expr_list (tree, int); static void dump_expr_list (cxx_pretty_printer *, tree, int);
static void dump_global_iord (tree); static void dump_global_iord (cxx_pretty_printer *, tree);
static void dump_parameters (tree, int); static void dump_parameters (cxx_pretty_printer *, tree, int);
static void dump_ref_qualifier (tree, int); static void dump_ref_qualifier (cxx_pretty_printer *, tree, int);
static void dump_exception_spec (tree, int); static void dump_exception_spec (cxx_pretty_printer *, tree, int);
static void dump_template_argument (tree, int); static void dump_template_argument (cxx_pretty_printer *, tree, int);
static void dump_template_argument_list (tree, int); static void dump_template_argument_list (cxx_pretty_printer *, tree, int);
static void dump_template_parameter (tree, int); static void dump_template_parameter (cxx_pretty_printer *, tree, int);
static void dump_template_bindings (tree, tree, vec<tree, va_gc> *); static void dump_template_bindings (cxx_pretty_printer *, tree, tree,
static void dump_scope (tree, int); vec<tree, va_gc> *);
static void dump_template_parms (tree, int, int); static void dump_scope (cxx_pretty_printer *, tree, int);
static void dump_template_parms (cxx_pretty_printer *, tree, int, int);
static int get_non_default_template_args_count (tree, int); static int get_non_default_template_args_count (tree, int);
static const char *function_category (tree); static const char *function_category (tree);
static void maybe_print_constexpr_context (diagnostic_context *); static void maybe_print_constexpr_context (diagnostic_context *);
...@@ -115,7 +116,7 @@ init_error (void) ...@@ -115,7 +116,7 @@ init_error (void)
/* Dump a scope, if deemed necessary. */ /* Dump a scope, if deemed necessary. */
static void static void
dump_scope (tree scope, int flags) dump_scope (cxx_pretty_printer *pp, tree scope, int flags)
{ {
int f = flags & (TFF_SCOPE | TFF_CHASE_TYPEDEF); int f = flags & (TFF_SCOPE | TFF_CHASE_TYPEDEF);
...@@ -126,39 +127,39 @@ dump_scope (tree scope, int flags) ...@@ -126,39 +127,39 @@ dump_scope (tree scope, int flags)
{ {
if (scope != global_namespace) if (scope != global_namespace)
{ {
dump_decl (scope, f); dump_decl (pp, scope, f);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
} }
} }
else if (AGGREGATE_TYPE_P (scope)) else if (AGGREGATE_TYPE_P (scope))
{ {
dump_type (scope, f); dump_type (pp, scope, f);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
} }
else if ((flags & TFF_SCOPE) && TREE_CODE (scope) == FUNCTION_DECL) else if ((flags & TFF_SCOPE) && TREE_CODE (scope) == FUNCTION_DECL)
{ {
dump_function_decl (scope, f); dump_function_decl (pp, scope, f);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
} }
} }
/* Dump the template ARGument under control of FLAGS. */ /* Dump the template ARGument under control of FLAGS. */
static void static void
dump_template_argument (tree arg, int flags) dump_template_argument (cxx_pretty_printer *pp, tree arg, int flags)
{ {
if (ARGUMENT_PACK_P (arg)) if (ARGUMENT_PACK_P (arg))
dump_template_argument_list (ARGUMENT_PACK_ARGS (arg), dump_template_argument_list (pp, ARGUMENT_PACK_ARGS (arg),
/* No default args in argument packs. */ /* No default args in argument packs. */
flags|TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS); flags|TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS);
else if (TYPE_P (arg) || TREE_CODE (arg) == TEMPLATE_DECL) else if (TYPE_P (arg) || TREE_CODE (arg) == TEMPLATE_DECL)
dump_type (arg, flags & ~TFF_CLASS_KEY_OR_ENUM); dump_type (pp, arg, flags & ~TFF_CLASS_KEY_OR_ENUM);
else else
{ {
if (TREE_CODE (arg) == TREE_LIST) if (TREE_CODE (arg) == TREE_LIST)
arg = TREE_VALUE (arg); arg = TREE_VALUE (arg);
dump_expr (arg, (flags | TFF_EXPR_IN_PARENS) & ~TFF_CLASS_KEY_OR_ENUM); dump_expr (pp, arg, (flags | TFF_EXPR_IN_PARENS) & ~TFF_CLASS_KEY_OR_ENUM);
} }
} }
...@@ -186,7 +187,7 @@ get_non_default_template_args_count (tree args, int flags) ...@@ -186,7 +187,7 @@ get_non_default_template_args_count (tree args, int flags)
of FLAGS. */ of FLAGS. */
static void static void
dump_template_argument_list (tree args, int flags) dump_template_argument_list (cxx_pretty_printer *pp, tree args, int flags)
{ {
int n = get_non_default_template_args_count (args, flags); int n = get_non_default_template_args_count (args, flags);
int need_comma = 0; int need_comma = 0;
...@@ -202,9 +203,9 @@ dump_template_argument_list (tree args, int flags) ...@@ -202,9 +203,9 @@ dump_template_argument_list (tree args, int flags)
if (need_comma if (need_comma
&& (!ARGUMENT_PACK_P (arg) && (!ARGUMENT_PACK_P (arg)
|| TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg)) > 0)) || TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg)) > 0))
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
dump_template_argument (arg, flags); dump_template_argument (pp, arg, flags);
need_comma = 1; need_comma = 1;
} }
} }
...@@ -212,7 +213,7 @@ dump_template_argument_list (tree args, int flags) ...@@ -212,7 +213,7 @@ dump_template_argument_list (tree args, int flags)
/* Dump a template parameter PARM (a TREE_LIST) under control of FLAGS. */ /* Dump a template parameter PARM (a TREE_LIST) under control of FLAGS. */
static void static void
dump_template_parameter (tree parm, int flags) dump_template_parameter (cxx_pretty_printer *pp, tree parm, int flags)
{ {
tree p; tree p;
tree a; tree a;
...@@ -227,29 +228,29 @@ dump_template_parameter (tree parm, int flags) ...@@ -227,29 +228,29 @@ dump_template_parameter (tree parm, int flags)
{ {
if (flags & TFF_DECL_SPECIFIERS) if (flags & TFF_DECL_SPECIFIERS)
{ {
pp_cxx_ws_string (cxx_pp, "class"); pp_cxx_ws_string (pp, "class");
if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (p))) if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (p)))
pp_cxx_ws_string (cxx_pp, "..."); pp_cxx_ws_string (pp, "...");
if (DECL_NAME (p)) if (DECL_NAME (p))
pp_cxx_tree_identifier (cxx_pp, DECL_NAME (p)); pp_cxx_tree_identifier (pp, DECL_NAME (p));
} }
else if (DECL_NAME (p)) else if (DECL_NAME (p))
pp_cxx_tree_identifier (cxx_pp, DECL_NAME (p)); pp_cxx_tree_identifier (pp, DECL_NAME (p));
else else
pp_cxx_canonical_template_parameter (cxx_pp, TREE_TYPE (p)); pp_cxx_canonical_template_parameter (pp, TREE_TYPE (p));
} }
else else
dump_decl (p, flags | TFF_DECL_SPECIFIERS); dump_decl (pp, p, flags | TFF_DECL_SPECIFIERS);
if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && a != NULL_TREE) if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && a != NULL_TREE)
{ {
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_equal (cxx_pp); pp_equal (pp);
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
if (TREE_CODE (p) == TYPE_DECL || TREE_CODE (p) == TEMPLATE_DECL) if (TREE_CODE (p) == TYPE_DECL || TREE_CODE (p) == TEMPLATE_DECL)
dump_type (a, flags & ~TFF_CHASE_TYPEDEF); dump_type (pp, a, flags & ~TFF_CHASE_TYPEDEF);
else else
dump_expr (a, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, a, flags | TFF_EXPR_IN_PARENS);
} }
} }
...@@ -258,7 +259,8 @@ dump_template_parameter (tree parm, int flags) ...@@ -258,7 +259,8 @@ dump_template_parameter (tree parm, int flags)
TREE_VEC. */ TREE_VEC. */
static void static void
dump_template_bindings (tree parms, tree args, vec<tree, va_gc> *typenames) dump_template_bindings (cxx_pretty_printer *pp, tree parms, tree args,
vec<tree, va_gc> *typenames)
{ {
bool need_semicolon = false; bool need_semicolon = false;
int i; int i;
...@@ -285,21 +287,22 @@ dump_template_bindings (tree parms, tree args, vec<tree, va_gc> *typenames) ...@@ -285,21 +287,22 @@ dump_template_bindings (tree parms, tree args, vec<tree, va_gc> *typenames)
arg = TREE_VEC_ELT (lvl_args, arg_idx); arg = TREE_VEC_ELT (lvl_args, arg_idx);
if (need_semicolon) if (need_semicolon)
pp_separate_with_semicolon (cxx_pp); pp_separate_with_semicolon (pp);
dump_template_parameter (TREE_VEC_ELT (p, i), TFF_PLAIN_IDENTIFIER); dump_template_parameter (pp, TREE_VEC_ELT (p, i),
pp_cxx_whitespace (cxx_pp); TFF_PLAIN_IDENTIFIER);
pp_equal (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_whitespace (cxx_pp); pp_equal (pp);
pp_cxx_whitespace (pp);
if (arg) if (arg)
{ {
if (ARGUMENT_PACK_P (arg)) if (ARGUMENT_PACK_P (arg))
pp_cxx_left_brace (cxx_pp); pp_cxx_left_brace (pp);
dump_template_argument (arg, TFF_PLAIN_IDENTIFIER); dump_template_argument (pp, arg, TFF_PLAIN_IDENTIFIER);
if (ARGUMENT_PACK_P (arg)) if (ARGUMENT_PACK_P (arg))
pp_cxx_right_brace (cxx_pp); pp_cxx_right_brace (pp);
} }
else else
pp_string (cxx_pp, M_("<missing>")); pp_string (pp, M_("<missing>"));
++arg_idx; ++arg_idx;
need_semicolon = true; need_semicolon = true;
...@@ -315,18 +318,18 @@ dump_template_bindings (tree parms, tree args, vec<tree, va_gc> *typenames) ...@@ -315,18 +318,18 @@ dump_template_bindings (tree parms, tree args, vec<tree, va_gc> *typenames)
FOR_EACH_VEC_SAFE_ELT (typenames, i, t) FOR_EACH_VEC_SAFE_ELT (typenames, i, t)
{ {
if (need_semicolon) if (need_semicolon)
pp_separate_with_semicolon (cxx_pp); pp_separate_with_semicolon (pp);
dump_type (t, TFF_PLAIN_IDENTIFIER); dump_type (pp, t, TFF_PLAIN_IDENTIFIER);
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_equal (cxx_pp); pp_equal (pp);
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
push_deferring_access_checks (dk_no_check); push_deferring_access_checks (dk_no_check);
t = tsubst (t, args, tf_none, NULL_TREE); t = tsubst (t, args, tf_none, NULL_TREE);
pop_deferring_access_checks (); pop_deferring_access_checks ();
/* Strip typedefs. We can't just use TFF_CHASE_TYPEDEF because /* Strip typedefs. We can't just use TFF_CHASE_TYPEDEF because
pp_simple_type_specifier doesn't know about it. */ pp_simple_type_specifier doesn't know about it. */
t = strip_typedefs (t); t = strip_typedefs (t);
dump_type (t, TFF_PLAIN_IDENTIFIER); dump_type (pp, t, TFF_PLAIN_IDENTIFIER);
} }
} }
...@@ -334,17 +337,17 @@ dump_template_bindings (tree parms, tree args, vec<tree, va_gc> *typenames) ...@@ -334,17 +337,17 @@ dump_template_bindings (tree parms, tree args, vec<tree, va_gc> *typenames)
specialization of T. */ specialization of T. */
static void static void
dump_alias_template_specialization (tree t, int flags) dump_alias_template_specialization (cxx_pretty_printer *pp, tree t, int flags)
{ {
tree name; tree name;
gcc_assert (alias_template_specialization_p (t)); gcc_assert (alias_template_specialization_p (t));
if (!(flags & TFF_UNQUALIFIED_NAME)) if (!(flags & TFF_UNQUALIFIED_NAME))
dump_scope (CP_DECL_CONTEXT (TYPE_NAME (t)), flags); dump_scope (pp, CP_DECL_CONTEXT (TYPE_NAME (t)), flags);
name = TYPE_IDENTIFIER (t); name = TYPE_IDENTIFIER (t);
pp_cxx_tree_identifier (cxx_pp, name); pp_cxx_tree_identifier (pp, name);
dump_template_parms (TYPE_TEMPLATE_INFO (t), dump_template_parms (pp, TYPE_TEMPLATE_INFO (t),
/*primary=*/false, /*primary=*/false,
flags & ~TFF_TEMPLATE_HEADER); flags & ~TFF_TEMPLATE_HEADER);
} }
...@@ -353,7 +356,7 @@ dump_alias_template_specialization (tree t, int flags) ...@@ -353,7 +356,7 @@ dump_alias_template_specialization (tree t, int flags)
format. */ format. */
static void static void
dump_type (tree t, int flags) dump_type (cxx_pretty_printer *pp, tree t, int flags)
{ {
if (t == NULL_TREE) if (t == NULL_TREE)
return; return;
...@@ -369,15 +372,15 @@ dump_type (tree t, int flags) ...@@ -369,15 +372,15 @@ dump_type (tree t, int flags)
t = strip_typedefs (t); t = strip_typedefs (t);
else if (alias_template_specialization_p (t)) else if (alias_template_specialization_p (t))
{ {
dump_alias_template_specialization (t, flags); dump_alias_template_specialization (pp, t, flags);
return; return;
} }
else if (same_type_p (t, TREE_TYPE (decl))) else if (same_type_p (t, TREE_TYPE (decl)))
t = decl; t = decl;
else else
{ {
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (pp, t);
pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
return; return;
} }
} }
...@@ -389,39 +392,39 @@ dump_type (tree t, int flags) ...@@ -389,39 +392,39 @@ dump_type (tree t, int flags)
{ {
case LANG_TYPE: case LANG_TYPE:
if (t == init_list_type_node) if (t == init_list_type_node)
pp_string (cxx_pp, M_("<brace-enclosed initializer list>")); pp_string (pp, M_("<brace-enclosed initializer list>"));
else if (t == unknown_type_node) else if (t == unknown_type_node)
pp_string (cxx_pp, M_("<unresolved overloaded function type>")); pp_string (pp, M_("<unresolved overloaded function type>"));
else else
{ {
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (pp, t);
pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
} }
break; break;
case TREE_LIST: case TREE_LIST:
/* A list of function parms. */ /* A list of function parms. */
dump_parameters (t, flags); dump_parameters (pp, t, flags);
break; break;
case IDENTIFIER_NODE: case IDENTIFIER_NODE:
pp_cxx_tree_identifier (cxx_pp, t); pp_cxx_tree_identifier (pp, t);
break; break;
case TREE_BINFO: case TREE_BINFO:
dump_type (BINFO_TYPE (t), flags); dump_type (pp, BINFO_TYPE (t), flags);
break; break;
case RECORD_TYPE: case RECORD_TYPE:
case UNION_TYPE: case UNION_TYPE:
case ENUMERAL_TYPE: case ENUMERAL_TYPE:
dump_aggr_type (t, flags); dump_aggr_type (pp, t, flags);
break; break;
case TYPE_DECL: case TYPE_DECL:
if (flags & TFF_CHASE_TYPEDEF) if (flags & TFF_CHASE_TYPEDEF)
{ {
dump_type (DECL_ORIGINAL_TYPE (t) dump_type (pp, DECL_ORIGINAL_TYPE (t)
? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), flags); ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), flags);
break; break;
} }
...@@ -429,7 +432,7 @@ dump_type (tree t, int flags) ...@@ -429,7 +432,7 @@ dump_type (tree t, int flags)
case TEMPLATE_DECL: case TEMPLATE_DECL:
case NAMESPACE_DECL: case NAMESPACE_DECL:
dump_decl (t, flags & ~TFF_DECL_SPECIFIERS); dump_decl (pp, t, flags & ~TFF_DECL_SPECIFIERS);
break; break;
case INTEGER_TYPE: case INTEGER_TYPE:
...@@ -439,35 +442,35 @@ dump_type (tree t, int flags) ...@@ -439,35 +442,35 @@ dump_type (tree t, int flags)
case COMPLEX_TYPE: case COMPLEX_TYPE:
case VECTOR_TYPE: case VECTOR_TYPE:
case FIXED_POINT_TYPE: case FIXED_POINT_TYPE:
pp_type_specifier_seq (cxx_pp, t); pp_type_specifier_seq (pp, t);
break; break;
case TEMPLATE_TEMPLATE_PARM: case TEMPLATE_TEMPLATE_PARM:
/* For parameters inside template signature. */ /* For parameters inside template signature. */
if (TYPE_IDENTIFIER (t)) if (TYPE_IDENTIFIER (t))
pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
else else
pp_cxx_canonical_template_parameter (cxx_pp, t); pp_cxx_canonical_template_parameter (pp, t);
break; break;
case BOUND_TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM:
{ {
tree args = TYPE_TI_ARGS (t); tree args = TYPE_TI_ARGS (t);
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (pp, t);
pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
pp_cxx_begin_template_argument_list (cxx_pp); pp_cxx_begin_template_argument_list (pp);
dump_template_argument_list (args, flags); dump_template_argument_list (pp, args, flags);
pp_cxx_end_template_argument_list (cxx_pp); pp_cxx_end_template_argument_list (pp);
} }
break; break;
case TEMPLATE_TYPE_PARM: case TEMPLATE_TYPE_PARM:
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (pp, t);
if (TYPE_IDENTIFIER (t)) if (TYPE_IDENTIFIER (t))
pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
else else
pp_cxx_canonical_template_parameter pp_cxx_canonical_template_parameter
(cxx_pp, TEMPLATE_TYPE_PARM_INDEX (t)); (pp, TEMPLATE_TYPE_PARM_INDEX (t));
break; break;
/* This is not always necessary for pointers and such, but doing this /* This is not always necessary for pointers and such, but doing this
...@@ -480,78 +483,78 @@ dump_type (tree t, int flags) ...@@ -480,78 +483,78 @@ dump_type (tree t, int flags)
case FUNCTION_TYPE: case FUNCTION_TYPE:
case METHOD_TYPE: case METHOD_TYPE:
{ {
dump_type_prefix (t, flags); dump_type_prefix (pp, t, flags);
dump_type_suffix (t, flags); dump_type_suffix (pp, t, flags);
break; break;
} }
case TYPENAME_TYPE: case TYPENAME_TYPE:
if (! (flags & TFF_CHASE_TYPEDEF) if (! (flags & TFF_CHASE_TYPEDEF)
&& DECL_ORIGINAL_TYPE (TYPE_NAME (t))) && DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
{ {
dump_decl (TYPE_NAME (t), TFF_PLAIN_IDENTIFIER); dump_decl (pp, TYPE_NAME (t), TFF_PLAIN_IDENTIFIER);
break; break;
} }
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (pp, t);
pp_cxx_ws_string (cxx_pp, pp_cxx_ws_string (pp,
TYPENAME_IS_ENUM_P (t) ? "enum" TYPENAME_IS_ENUM_P (t) ? "enum"
: TYPENAME_IS_CLASS_P (t) ? "class" : TYPENAME_IS_CLASS_P (t) ? "class"
: "typename"); : "typename");
dump_typename (t, flags); dump_typename (pp, t, flags);
break; break;
case UNBOUND_CLASS_TEMPLATE: case UNBOUND_CLASS_TEMPLATE:
if (! (flags & TFF_UNQUALIFIED_NAME)) if (! (flags & TFF_UNQUALIFIED_NAME))
{ {
dump_type (TYPE_CONTEXT (t), flags); dump_type (pp, TYPE_CONTEXT (t), flags);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
} }
pp_cxx_ws_string (cxx_pp, "template"); pp_cxx_ws_string (pp, "template");
dump_type (DECL_NAME (TYPE_NAME (t)), flags); dump_type (pp, DECL_NAME (TYPE_NAME (t)), flags);
break; break;
case TYPEOF_TYPE: case TYPEOF_TYPE:
pp_cxx_ws_string (cxx_pp, "__typeof__"); pp_cxx_ws_string (pp, "__typeof__");
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (TYPEOF_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, TYPEOF_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case UNDERLYING_TYPE: case UNDERLYING_TYPE:
pp_cxx_ws_string (cxx_pp, "__underlying_type"); pp_cxx_ws_string (pp, "__underlying_type");
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (UNDERLYING_TYPE_TYPE (t), flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, UNDERLYING_TYPE_TYPE (t), flags & ~TFF_EXPR_IN_PARENS);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case TYPE_PACK_EXPANSION: case TYPE_PACK_EXPANSION:
dump_type (PACK_EXPANSION_PATTERN (t), flags); dump_type (pp, PACK_EXPANSION_PATTERN (t), flags);
pp_cxx_ws_string (cxx_pp, "..."); pp_cxx_ws_string (pp, "...");
break; break;
case TYPE_ARGUMENT_PACK: case TYPE_ARGUMENT_PACK:
dump_template_argument (t, flags); dump_template_argument (pp, t, flags);
break; break;
case DECLTYPE_TYPE: case DECLTYPE_TYPE:
pp_cxx_ws_string (cxx_pp, "decltype"); pp_cxx_ws_string (pp, "decltype");
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (DECLTYPE_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, DECLTYPE_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case NULLPTR_TYPE: case NULLPTR_TYPE:
pp_string (cxx_pp, "std::nullptr_t"); pp_string (pp, "std::nullptr_t");
break; break;
default: default:
pp_unsupported_tree (cxx_pp, t); pp_unsupported_tree (pp, t);
/* Fall through to error. */ /* Fall through to error. */
case ERROR_MARK: case ERROR_MARK:
pp_string (cxx_pp, M_("<type error>")); pp_string (pp, M_("<type error>"));
break; break;
} }
} }
...@@ -560,16 +563,16 @@ dump_type (tree t, int flags) ...@@ -560,16 +563,16 @@ dump_type (tree t, int flags)
a TYPENAME_TYPE. */ a TYPENAME_TYPE. */
static void static void
dump_typename (tree t, int flags) dump_typename (cxx_pretty_printer *pp, tree t, int flags)
{ {
tree ctx = TYPE_CONTEXT (t); tree ctx = TYPE_CONTEXT (t);
if (TREE_CODE (ctx) == TYPENAME_TYPE) if (TREE_CODE (ctx) == TYPENAME_TYPE)
dump_typename (ctx, flags); dump_typename (pp, ctx, flags);
else else
dump_type (ctx, flags & ~TFF_CLASS_KEY_OR_ENUM); dump_type (pp, ctx, flags & ~TFF_CLASS_KEY_OR_ENUM);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
dump_decl (TYPENAME_TYPE_FULLNAME (t), flags); dump_decl (pp, TYPENAME_TYPE_FULLNAME (t), flags);
} }
/* Return the name of the supplied aggregate, or enumeral type. */ /* Return the name of the supplied aggregate, or enumeral type. */
...@@ -596,17 +599,17 @@ class_key_or_enum_as_string (tree t) ...@@ -596,17 +599,17 @@ class_key_or_enum_as_string (tree t)
in the form `class foo'. */ in the form `class foo'. */
static void static void
dump_aggr_type (tree t, int flags) dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags)
{ {
tree name; tree name;
const char *variety = class_key_or_enum_as_string (t); const char *variety = class_key_or_enum_as_string (t);
int typdef = 0; int typdef = 0;
int tmplate = 0; int tmplate = 0;
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (pp, t);
if (flags & TFF_CLASS_KEY_OR_ENUM) if (flags & TFF_CLASS_KEY_OR_ENUM)
pp_cxx_ws_string (cxx_pp, variety); pp_cxx_ws_string (pp, variety);
name = TYPE_NAME (t); name = TYPE_NAME (t);
...@@ -634,7 +637,7 @@ dump_aggr_type (tree t, int flags) ...@@ -634,7 +637,7 @@ dump_aggr_type (tree t, int flags)
|| PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t))); || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t)));
if (! (flags & TFF_UNQUALIFIED_NAME)) if (! (flags & TFF_UNQUALIFIED_NAME))
dump_scope (CP_DECL_CONTEXT (name), flags | TFF_SCOPE); dump_scope (pp, CP_DECL_CONTEXT (name), flags | TFF_SCOPE);
flags &= ~TFF_UNQUALIFIED_NAME; flags &= ~TFF_UNQUALIFIED_NAME;
if (tmplate) if (tmplate)
{ {
...@@ -652,23 +655,24 @@ dump_aggr_type (tree t, int flags) ...@@ -652,23 +655,24 @@ dump_aggr_type (tree t, int flags)
if (name == 0 || ANON_AGGRNAME_P (name)) if (name == 0 || ANON_AGGRNAME_P (name))
{ {
if (flags & TFF_CLASS_KEY_OR_ENUM) if (flags & TFF_CLASS_KEY_OR_ENUM)
pp_string (cxx_pp, M_("<anonymous>")); pp_string (pp, M_("<anonymous>"));
else else
pp_printf (cxx_pp, M_("<anonymous %s>"), variety); pp_printf (pp, M_("<anonymous %s>"), variety);
} }
else if (LAMBDA_TYPE_P (t)) else if (LAMBDA_TYPE_P (t))
{ {
/* A lambda's "type" is essentially its signature. */ /* A lambda's "type" is essentially its signature. */
pp_string (cxx_pp, M_("<lambda")); pp_string (pp, M_("<lambda"));
if (lambda_function (t)) if (lambda_function (t))
dump_parameters (FUNCTION_FIRST_USER_PARMTYPE (lambda_function (t)), dump_parameters (pp,
FUNCTION_FIRST_USER_PARMTYPE (lambda_function (t)),
flags); flags);
pp_greater (cxx_pp); pp_greater (pp);
} }
else else
pp_cxx_tree_identifier (cxx_pp, name); pp_cxx_tree_identifier (pp, name);
if (tmplate) if (tmplate)
dump_template_parms (TYPE_TEMPLATE_INFO (t), dump_template_parms (pp, TYPE_TEMPLATE_INFO (t),
!CLASSTYPE_USE_TEMPLATE (t), !CLASSTYPE_USE_TEMPLATE (t),
flags & ~TFF_TEMPLATE_HEADER); flags & ~TFF_TEMPLATE_HEADER);
} }
...@@ -685,7 +689,7 @@ dump_aggr_type (tree t, int flags) ...@@ -685,7 +689,7 @@ dump_aggr_type (tree t, int flags)
int *[]&. */ int *[]&. */
static void static void
dump_type_prefix (tree t, int flags) dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags)
{ {
if (TYPE_PTRMEMFUNC_P (t)) if (TYPE_PTRMEMFUNC_P (t))
{ {
...@@ -700,60 +704,60 @@ dump_type_prefix (tree t, int flags) ...@@ -700,60 +704,60 @@ dump_type_prefix (tree t, int flags)
{ {
tree sub = TREE_TYPE (t); tree sub = TREE_TYPE (t);
dump_type_prefix (sub, flags); dump_type_prefix (pp, sub, flags);
if (TREE_CODE (sub) == ARRAY_TYPE if (TREE_CODE (sub) == ARRAY_TYPE
|| TREE_CODE (sub) == FUNCTION_TYPE) || TREE_CODE (sub) == FUNCTION_TYPE)
{ {
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
pp_c_attributes_display (cxx_pp, TYPE_ATTRIBUTES (sub)); pp_c_attributes_display (pp, TYPE_ATTRIBUTES (sub));
} }
if (TYPE_PTR_P (t)) if (TYPE_PTR_P (t))
pp_star (cxx_pp); pp_star (pp);
else if (TREE_CODE (t) == REFERENCE_TYPE) else if (TREE_CODE (t) == REFERENCE_TYPE)
{ {
if (TYPE_REF_IS_RVALUE (t)) if (TYPE_REF_IS_RVALUE (t))
pp_ampersand_ampersand (cxx_pp); pp_ampersand_ampersand (pp);
else else
pp_ampersand (cxx_pp); pp_ampersand (pp);
} }
cxx_pp->padding = pp_before; pp->padding = pp_before;
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (pp, t);
} }
break; break;
case OFFSET_TYPE: case OFFSET_TYPE:
offset_type: offset_type:
dump_type_prefix (TREE_TYPE (t), flags); dump_type_prefix (pp, TREE_TYPE (t), flags);
if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */ if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */
{ {
pp_maybe_space (cxx_pp); pp_maybe_space (pp);
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_type (TYPE_OFFSET_BASETYPE (t), flags); dump_type (pp, TYPE_OFFSET_BASETYPE (t), flags);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
} }
pp_cxx_star (cxx_pp); pp_cxx_star (pp);
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (pp, t);
cxx_pp->padding = pp_before; pp->padding = pp_before;
break; break;
/* This can be reached without a pointer when dealing with /* This can be reached without a pointer when dealing with
templates, e.g. std::is_function. */ templates, e.g. std::is_function. */
case FUNCTION_TYPE: case FUNCTION_TYPE:
dump_type_prefix (TREE_TYPE (t), flags); dump_type_prefix (pp, TREE_TYPE (t), flags);
break; break;
case METHOD_TYPE: case METHOD_TYPE:
dump_type_prefix (TREE_TYPE (t), flags); dump_type_prefix (pp, TREE_TYPE (t), flags);
pp_maybe_space (cxx_pp); pp_maybe_space (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_aggr_type (TYPE_METHOD_BASETYPE (t), flags); dump_aggr_type (pp, TYPE_METHOD_BASETYPE (t), flags);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
break; break;
case ARRAY_TYPE: case ARRAY_TYPE:
dump_type_prefix (TREE_TYPE (t), flags); dump_type_prefix (pp, TREE_TYPE (t), flags);
break; break;
case ENUMERAL_TYPE: case ENUMERAL_TYPE:
...@@ -780,15 +784,15 @@ dump_type_prefix (tree t, int flags) ...@@ -780,15 +784,15 @@ dump_type_prefix (tree t, int flags)
case TYPE_PACK_EXPANSION: case TYPE_PACK_EXPANSION:
case FIXED_POINT_TYPE: case FIXED_POINT_TYPE:
case NULLPTR_TYPE: case NULLPTR_TYPE:
dump_type (t, flags); dump_type (pp, t, flags);
cxx_pp->padding = pp_before; pp->padding = pp_before;
break; break;
default: default:
pp_unsupported_tree (cxx_pp, t); pp_unsupported_tree (pp, t);
/* fall through. */ /* fall through. */
case ERROR_MARK: case ERROR_MARK:
pp_string (cxx_pp, M_("<typeprefixerror>")); pp_string (pp, M_("<typeprefixerror>"));
break; break;
} }
} }
...@@ -797,7 +801,7 @@ dump_type_prefix (tree t, int flags) ...@@ -797,7 +801,7 @@ dump_type_prefix (tree t, int flags)
which appears after the identifier (or function parms). */ which appears after the identifier (or function parms). */
static void static void
dump_type_suffix (tree t, int flags) dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags)
{ {
if (TYPE_PTRMEMFUNC_P (t)) if (TYPE_PTRMEMFUNC_P (t))
t = TYPE_PTRMEMFUNC_FN_TYPE (t); t = TYPE_PTRMEMFUNC_FN_TYPE (t);
...@@ -809,8 +813,8 @@ dump_type_suffix (tree t, int flags) ...@@ -809,8 +813,8 @@ dump_type_suffix (tree t, int flags)
case OFFSET_TYPE: case OFFSET_TYPE:
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
|| TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
dump_type_suffix (TREE_TYPE (t), flags); dump_type_suffix (pp, TREE_TYPE (t), flags);
break; break;
case FUNCTION_TYPE: case FUNCTION_TYPE:
...@@ -819,34 +823,34 @@ dump_type_suffix (tree t, int flags) ...@@ -819,34 +823,34 @@ dump_type_suffix (tree t, int flags)
tree arg; tree arg;
if (TREE_CODE (t) == METHOD_TYPE) if (TREE_CODE (t) == METHOD_TYPE)
/* Can only be reached through a pointer. */ /* Can only be reached through a pointer. */
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
arg = TYPE_ARG_TYPES (t); arg = TYPE_ARG_TYPES (t);
if (TREE_CODE (t) == METHOD_TYPE) if (TREE_CODE (t) == METHOD_TYPE)
arg = TREE_CHAIN (arg); arg = TREE_CHAIN (arg);
/* Function pointers don't have default args. Not in standard C++, /* Function pointers don't have default args. Not in standard C++,
anyway; they may in g++, but we'll just pretend otherwise. */ anyway; they may in g++, but we'll just pretend otherwise. */
dump_parameters (arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS); dump_parameters (pp, arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS);
cxx_pp->padding = pp_before; pp->padding = pp_before;
pp_cxx_cv_qualifiers (cxx_pp, type_memfn_quals (t)); pp_cxx_cv_qualifiers (pp, type_memfn_quals (t));
dump_ref_qualifier (t, flags); dump_ref_qualifier (pp, t, flags);
dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), flags); dump_exception_spec (pp, TYPE_RAISES_EXCEPTIONS (t), flags);
dump_type_suffix (TREE_TYPE (t), flags); dump_type_suffix (pp, TREE_TYPE (t), flags);
break; break;
} }
case ARRAY_TYPE: case ARRAY_TYPE:
pp_maybe_space (cxx_pp); pp_maybe_space (pp);
pp_cxx_left_bracket (cxx_pp); pp_cxx_left_bracket (pp);
if (TYPE_DOMAIN (t)) if (TYPE_DOMAIN (t))
{ {
tree dtype = TYPE_DOMAIN (t); tree dtype = TYPE_DOMAIN (t);
tree max = TYPE_MAX_VALUE (dtype); tree max = TYPE_MAX_VALUE (dtype);
if (integer_all_onesp (max)) if (integer_all_onesp (max))
pp_character (cxx_pp, '0'); pp_character (pp, '0');
else if (host_integerp (max, 0)) else if (host_integerp (max, 0))
pp_wide_integer (cxx_pp, tree_low_cst (max, 0) + 1); pp_wide_integer (pp, tree_low_cst (max, 0) + 1);
else else
{ {
STRIP_NOPS (max); STRIP_NOPS (max);
...@@ -863,11 +867,11 @@ dump_type_suffix (tree t, int flags) ...@@ -863,11 +867,11 @@ dump_type_suffix (tree t, int flags)
max = fold_build2_loc (input_location, max = fold_build2_loc (input_location,
PLUS_EXPR, dtype, max, PLUS_EXPR, dtype, max,
build_int_cst (dtype, 1)); build_int_cst (dtype, 1));
dump_expr (max, flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, max, flags & ~TFF_EXPR_IN_PARENS);
} }
} }
pp_cxx_right_bracket (cxx_pp); pp_cxx_right_bracket (pp);
dump_type_suffix (TREE_TYPE (t), flags); dump_type_suffix (pp, TREE_TYPE (t), flags);
break; break;
case ENUMERAL_TYPE: case ENUMERAL_TYPE:
...@@ -897,7 +901,7 @@ dump_type_suffix (tree t, int flags) ...@@ -897,7 +901,7 @@ dump_type_suffix (tree t, int flags)
break; break;
default: default:
pp_unsupported_tree (cxx_pp, t); pp_unsupported_tree (pp, t);
case ERROR_MARK: case ERROR_MARK:
/* Don't mark it here, we should have already done in /* Don't mark it here, we should have already done in
dump_type_prefix. */ dump_type_prefix. */
...@@ -906,7 +910,7 @@ dump_type_suffix (tree t, int flags) ...@@ -906,7 +910,7 @@ dump_type_suffix (tree t, int flags)
} }
static void static void
dump_global_iord (tree t) dump_global_iord (cxx_pretty_printer *pp, tree t)
{ {
const char *p = NULL; const char *p = NULL;
...@@ -917,51 +921,51 @@ dump_global_iord (tree t) ...@@ -917,51 +921,51 @@ dump_global_iord (tree t)
else else
gcc_unreachable (); gcc_unreachable ();
pp_printf (cxx_pp, p, input_filename); pp_printf (pp, p, input_filename);
} }
static void static void
dump_simple_decl (tree t, tree type, int flags) dump_simple_decl (cxx_pretty_printer *pp, tree t, tree type, int flags)
{ {
if (flags & TFF_DECL_SPECIFIERS) if (flags & TFF_DECL_SPECIFIERS)
{ {
if (VAR_P (t) if (VAR_P (t)
&& DECL_DECLARED_CONSTEXPR_P (t)) && DECL_DECLARED_CONSTEXPR_P (t))
pp_cxx_ws_string (cxx_pp, "constexpr"); pp_cxx_ws_string (pp, "constexpr");
dump_type_prefix (type, flags & ~TFF_UNQUALIFIED_NAME); dump_type_prefix (pp, type, flags & ~TFF_UNQUALIFIED_NAME);
pp_maybe_space (cxx_pp); pp_maybe_space (pp);
} }
if (! (flags & TFF_UNQUALIFIED_NAME) if (! (flags & TFF_UNQUALIFIED_NAME)
&& TREE_CODE (t) != PARM_DECL && TREE_CODE (t) != PARM_DECL
&& (!DECL_INITIAL (t) && (!DECL_INITIAL (t)
|| TREE_CODE (DECL_INITIAL (t)) != TEMPLATE_PARM_INDEX)) || TREE_CODE (DECL_INITIAL (t)) != TEMPLATE_PARM_INDEX))
dump_scope (CP_DECL_CONTEXT (t), flags); dump_scope (pp, CP_DECL_CONTEXT (t), flags);
flags &= ~TFF_UNQUALIFIED_NAME; flags &= ~TFF_UNQUALIFIED_NAME;
if ((flags & TFF_DECL_SPECIFIERS) if ((flags & TFF_DECL_SPECIFIERS)
&& DECL_TEMPLATE_PARM_P (t) && DECL_TEMPLATE_PARM_P (t)
&& TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (t))) && TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (t)))
pp_string (cxx_pp, "..."); pp_string (pp, "...");
if (DECL_NAME (t)) if (DECL_NAME (t))
{ {
if (TREE_CODE (t) == FIELD_DECL && DECL_NORMAL_CAPTURE_P (t)) if (TREE_CODE (t) == FIELD_DECL && DECL_NORMAL_CAPTURE_P (t))
{ {
pp_less (cxx_pp); pp_less (pp);
pp_string (cxx_pp, IDENTIFIER_POINTER (DECL_NAME (t)) + 2); pp_string (pp, IDENTIFIER_POINTER (DECL_NAME (t)) + 2);
pp_string (cxx_pp, " capture>"); pp_string (pp, " capture>");
} }
else else
dump_decl (DECL_NAME (t), flags); dump_decl (pp, DECL_NAME (t), flags);
} }
else else
pp_string (cxx_pp, M_("<anonymous>")); pp_string (pp, M_("<anonymous>"));
if (flags & TFF_DECL_SPECIFIERS) if (flags & TFF_DECL_SPECIFIERS)
dump_type_suffix (type, flags); dump_type_suffix (pp, type, flags);
} }
/* Dump a human readable string for the decl T under control of FLAGS. */ /* Dump a human readable string for the decl T under control of FLAGS. */
static void static void
dump_decl (tree t, int flags) dump_decl (cxx_pretty_printer *pp, tree t, int flags)
{ {
if (t == NULL_TREE) if (t == NULL_TREE)
return; return;
...@@ -973,7 +977,7 @@ dump_decl (tree t, int flags) ...@@ -973,7 +977,7 @@ dump_decl (tree t, int flags)
const char *demangled = objc_maybe_printable_name (t, flags); const char *demangled = objc_maybe_printable_name (t, flags);
if (demangled) if (demangled)
{ {
pp_string (cxx_pp, demangled); pp_string (pp, demangled);
return; return;
} }
} }
...@@ -988,32 +992,32 @@ dump_decl (tree t, int flags) ...@@ -988,32 +992,32 @@ dump_decl (tree t, int flags)
&& TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM) && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
{ {
/* Say `class T' not just `T'. */ /* Say `class T' not just `T'. */
pp_cxx_ws_string (cxx_pp, "class"); pp_cxx_ws_string (pp, "class");
/* Emit the `...' for a parameter pack. */ /* Emit the `...' for a parameter pack. */
if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (t))) if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (t)))
pp_cxx_ws_string (cxx_pp, "..."); pp_cxx_ws_string (pp, "...");
} }
dump_type (TREE_TYPE (t), flags); dump_type (pp, TREE_TYPE (t), flags);
break; break;
} }
if (TYPE_DECL_ALIAS_P (t) if (TYPE_DECL_ALIAS_P (t)
&& (flags & TFF_DECL_SPECIFIERS && (flags & TFF_DECL_SPECIFIERS
|| flags & TFF_CLASS_KEY_OR_ENUM)) || flags & TFF_CLASS_KEY_OR_ENUM))
{ {
pp_cxx_ws_string (cxx_pp, "using"); pp_cxx_ws_string (pp, "using");
dump_decl (DECL_NAME (t), flags); dump_decl (pp, DECL_NAME (t), flags);
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_ws_string (cxx_pp, "="); pp_cxx_ws_string (pp, "=");
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
dump_type (DECL_ORIGINAL_TYPE (t), flags); dump_type (pp, DECL_ORIGINAL_TYPE (t), flags);
break; break;
} }
if ((flags & TFF_DECL_SPECIFIERS) if ((flags & TFF_DECL_SPECIFIERS)
&& !DECL_SELF_REFERENCE_P (t)) && !DECL_SELF_REFERENCE_P (t))
pp_cxx_ws_string (cxx_pp, "typedef"); pp_cxx_ws_string (pp, "typedef");
dump_simple_decl (t, DECL_ORIGINAL_TYPE (t) dump_simple_decl (pp, t, DECL_ORIGINAL_TYPE (t)
? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t),
flags); flags);
break; break;
...@@ -1021,78 +1025,78 @@ dump_decl (tree t, int flags) ...@@ -1021,78 +1025,78 @@ dump_decl (tree t, int flags)
case VAR_DECL: case VAR_DECL:
if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t))) if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t)))
{ {
pp_string (cxx_pp, M_("vtable for ")); pp_string (pp, M_("vtable for "));
gcc_assert (TYPE_P (DECL_CONTEXT (t))); gcc_assert (TYPE_P (DECL_CONTEXT (t)));
dump_type (DECL_CONTEXT (t), flags); dump_type (pp, DECL_CONTEXT (t), flags);
break; break;
} }
/* Else fall through. */ /* Else fall through. */
case FIELD_DECL: case FIELD_DECL:
case PARM_DECL: case PARM_DECL:
dump_simple_decl (t, TREE_TYPE (t), flags); dump_simple_decl (pp, t, TREE_TYPE (t), flags);
break; break;
case RESULT_DECL: case RESULT_DECL:
pp_string (cxx_pp, M_("<return value> ")); pp_string (pp, M_("<return value> "));
dump_simple_decl (t, TREE_TYPE (t), flags); dump_simple_decl (pp, t, TREE_TYPE (t), flags);
break; break;
case NAMESPACE_DECL: case NAMESPACE_DECL:
if (flags & TFF_DECL_SPECIFIERS) if (flags & TFF_DECL_SPECIFIERS)
pp_cxx_declaration (cxx_pp, t); pp_cxx_declaration (pp, t);
else else
{ {
if (! (flags & TFF_UNQUALIFIED_NAME)) if (! (flags & TFF_UNQUALIFIED_NAME))
dump_scope (CP_DECL_CONTEXT (t), flags); dump_scope (pp, CP_DECL_CONTEXT (t), flags);
flags &= ~TFF_UNQUALIFIED_NAME; flags &= ~TFF_UNQUALIFIED_NAME;
if (DECL_NAME (t) == NULL_TREE) if (DECL_NAME (t) == NULL_TREE)
{ {
if (!(cxx_pp->flags & pp_c_flag_gnu_v3)) if (!(pp->flags & pp_c_flag_gnu_v3))
pp_cxx_ws_string (cxx_pp, M_("{anonymous}")); pp_cxx_ws_string (pp, M_("{anonymous}"));
else else
pp_cxx_ws_string (cxx_pp, M_("(anonymous namespace)")); pp_cxx_ws_string (pp, M_("(anonymous namespace)"));
} }
else else
pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); pp_cxx_tree_identifier (pp, DECL_NAME (t));
} }
break; break;
case SCOPE_REF: case SCOPE_REF:
dump_type (TREE_OPERAND (t, 0), flags); dump_type (pp, TREE_OPERAND (t, 0), flags);
pp_colon_colon (cxx_pp); pp_colon_colon (pp);
dump_decl (TREE_OPERAND (t, 1), TFF_UNQUALIFIED_NAME); dump_decl (pp, TREE_OPERAND (t, 1), TFF_UNQUALIFIED_NAME);
break; break;
case ARRAY_REF: case ARRAY_REF:
dump_decl (TREE_OPERAND (t, 0), flags); dump_decl (pp, TREE_OPERAND (t, 0), flags);
pp_cxx_left_bracket (cxx_pp); pp_cxx_left_bracket (pp);
dump_decl (TREE_OPERAND (t, 1), flags); dump_decl (pp, TREE_OPERAND (t, 1), flags);
pp_cxx_right_bracket (cxx_pp); pp_cxx_right_bracket (pp);
break; break;
case ARRAY_NOTATION_REF: case ARRAY_NOTATION_REF:
dump_decl (ARRAY_NOTATION_ARRAY (t), flags | TFF_EXPR_IN_PARENS); dump_decl (pp, ARRAY_NOTATION_ARRAY (t), flags | TFF_EXPR_IN_PARENS);
pp_cxx_left_bracket (cxx_pp); pp_cxx_left_bracket (pp);
dump_decl (ARRAY_NOTATION_START (t), flags | TFF_EXPR_IN_PARENS); dump_decl (pp, ARRAY_NOTATION_START (t), flags | TFF_EXPR_IN_PARENS);
pp_colon (cxx_pp); pp_colon (pp);
dump_decl (ARRAY_NOTATION_LENGTH (t), flags | TFF_EXPR_IN_PARENS); dump_decl (pp, ARRAY_NOTATION_LENGTH (t), flags | TFF_EXPR_IN_PARENS);
pp_colon (cxx_pp); pp_colon (pp);
dump_decl (ARRAY_NOTATION_STRIDE (t), flags | TFF_EXPR_IN_PARENS); dump_decl (pp, ARRAY_NOTATION_STRIDE (t), flags | TFF_EXPR_IN_PARENS);
pp_cxx_right_bracket (cxx_pp); pp_cxx_right_bracket (pp);
break; break;
/* So that we can do dump_decl on an aggr type. */ /* So that we can do dump_decl on an aggr type. */
case RECORD_TYPE: case RECORD_TYPE:
case UNION_TYPE: case UNION_TYPE:
case ENUMERAL_TYPE: case ENUMERAL_TYPE:
dump_type (t, flags); dump_type (pp, t, flags);
break; break;
case BIT_NOT_EXPR: case BIT_NOT_EXPR:
/* This is a pseudo destructor call which has not been folded into /* This is a pseudo destructor call which has not been folded into
a PSEUDO_DTOR_EXPR yet. */ a PSEUDO_DTOR_EXPR yet. */
pp_cxx_complement (cxx_pp); pp_cxx_complement (pp);
dump_type (TREE_OPERAND (t, 0), flags); dump_type (pp, TREE_OPERAND (t, 0), flags);
break; break;
case TYPE_EXPR: case TYPE_EXPR:
...@@ -1104,13 +1108,13 @@ dump_decl (tree t, int flags) ...@@ -1104,13 +1108,13 @@ dump_decl (tree t, int flags)
case IDENTIFIER_NODE: case IDENTIFIER_NODE:
if (IDENTIFIER_TYPENAME_P (t)) if (IDENTIFIER_TYPENAME_P (t))
{ {
pp_cxx_ws_string (cxx_pp, "operator"); pp_cxx_ws_string (pp, "operator");
/* Not exactly IDENTIFIER_TYPE_VALUE. */ /* Not exactly IDENTIFIER_TYPE_VALUE. */
dump_type (TREE_TYPE (t), flags); dump_type (pp, TREE_TYPE (t), flags);
break; break;
} }
else else
pp_cxx_tree_identifier (cxx_pp, t); pp_cxx_tree_identifier (pp, t);
break; break;
case OVERLOAD: case OVERLOAD:
...@@ -1119,15 +1123,15 @@ dump_decl (tree t, int flags) ...@@ -1119,15 +1123,15 @@ dump_decl (tree t, int flags)
t = OVL_CURRENT (t); t = OVL_CURRENT (t);
if (DECL_CLASS_SCOPE_P (t)) if (DECL_CLASS_SCOPE_P (t))
{ {
dump_type (DECL_CONTEXT (t), flags); dump_type (pp, DECL_CONTEXT (t), flags);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
} }
else if (!DECL_FILE_SCOPE_P (t)) else if (!DECL_FILE_SCOPE_P (t))
{ {
dump_decl (DECL_CONTEXT (t), flags); dump_decl (pp, DECL_CONTEXT (t), flags);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
} }
dump_decl (DECL_NAME (t), flags); dump_decl (pp, DECL_NAME (t), flags);
break; break;
} }
...@@ -1138,15 +1142,15 @@ dump_decl (tree t, int flags) ...@@ -1138,15 +1142,15 @@ dump_decl (tree t, int flags)
case FUNCTION_DECL: case FUNCTION_DECL:
if (! DECL_LANG_SPECIFIC (t)) if (! DECL_LANG_SPECIFIC (t))
pp_string (cxx_pp, M_("<built-in>")); pp_string (pp, M_("<built-in>"));
else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t)) else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
dump_global_iord (t); dump_global_iord (pp, t);
else else
dump_function_decl (t, flags); dump_function_decl (pp, t, flags);
break; break;
case TEMPLATE_DECL: case TEMPLATE_DECL:
dump_template_decl (t, flags); dump_template_decl (pp, t, flags);
break; break;
case TEMPLATE_ID_EXPR: case TEMPLATE_ID_EXPR:
...@@ -1156,71 +1160,71 @@ dump_decl (tree t, int flags) ...@@ -1156,71 +1160,71 @@ dump_decl (tree t, int flags)
if (is_overloaded_fn (name)) if (is_overloaded_fn (name))
name = DECL_NAME (get_first_fn (name)); name = DECL_NAME (get_first_fn (name));
dump_decl (name, flags); dump_decl (pp, name, flags);
pp_cxx_begin_template_argument_list (cxx_pp); pp_cxx_begin_template_argument_list (pp);
if (args == error_mark_node) if (args == error_mark_node)
pp_string (cxx_pp, M_("<template arguments error>")); pp_string (pp, M_("<template arguments error>"));
else if (args) else if (args)
dump_template_argument_list (args, flags); dump_template_argument_list (pp, args, flags);
pp_cxx_end_template_argument_list (cxx_pp); pp_cxx_end_template_argument_list (pp);
} }
break; break;
case LABEL_DECL: case LABEL_DECL:
pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); pp_cxx_tree_identifier (pp, DECL_NAME (t));
break; break;
case CONST_DECL: case CONST_DECL:
if ((TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == ENUMERAL_TYPE) if ((TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == ENUMERAL_TYPE)
|| (DECL_INITIAL (t) && || (DECL_INITIAL (t) &&
TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_PARM_INDEX)) TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_PARM_INDEX))
dump_simple_decl (t, TREE_TYPE (t), flags); dump_simple_decl (pp, t, TREE_TYPE (t), flags);
else if (DECL_NAME (t)) else if (DECL_NAME (t))
dump_decl (DECL_NAME (t), flags); dump_decl (pp, DECL_NAME (t), flags);
else if (DECL_INITIAL (t)) else if (DECL_INITIAL (t))
dump_expr (DECL_INITIAL (t), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, DECL_INITIAL (t), flags | TFF_EXPR_IN_PARENS);
else else
pp_string (cxx_pp, M_("<enumerator>")); pp_string (pp, M_("<enumerator>"));
break; break;
case USING_DECL: case USING_DECL:
pp_cxx_ws_string (cxx_pp, "using"); pp_cxx_ws_string (pp, "using");
dump_type (USING_DECL_SCOPE (t), flags); dump_type (pp, USING_DECL_SCOPE (t), flags);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
dump_decl (DECL_NAME (t), flags); dump_decl (pp, DECL_NAME (t), flags);
break; break;
case STATIC_ASSERT: case STATIC_ASSERT:
pp_cxx_declaration (cxx_pp, t); pp_cxx_declaration (pp, t);
break; break;
case BASELINK: case BASELINK:
dump_decl (BASELINK_FUNCTIONS (t), flags); dump_decl (pp, BASELINK_FUNCTIONS (t), flags);
break; break;
case NON_DEPENDENT_EXPR: case NON_DEPENDENT_EXPR:
dump_expr (t, flags); dump_expr (pp, t, flags);
break; break;
case TEMPLATE_TYPE_PARM: case TEMPLATE_TYPE_PARM:
if (flags & TFF_DECL_SPECIFIERS) if (flags & TFF_DECL_SPECIFIERS)
pp_cxx_declaration (cxx_pp, t); pp_cxx_declaration (pp, t);
else else
pp_type_id (cxx_pp, t); pp_type_id (pp, t);
break; break;
case UNBOUND_CLASS_TEMPLATE: case UNBOUND_CLASS_TEMPLATE:
case TYPE_PACK_EXPANSION: case TYPE_PACK_EXPANSION:
case TREE_BINFO: case TREE_BINFO:
dump_type (t, flags); dump_type (pp, t, flags);
break; break;
default: default:
pp_unsupported_tree (cxx_pp, t); pp_unsupported_tree (pp, t);
/* Fall through to error. */ /* Fall through to error. */
case ERROR_MARK: case ERROR_MARK:
pp_string (cxx_pp, M_("<declaration error>")); pp_string (pp, M_("<declaration error>"));
break; break;
} }
} }
...@@ -1229,7 +1233,7 @@ dump_decl (tree t, int flags) ...@@ -1229,7 +1233,7 @@ dump_decl (tree t, int flags)
'template <...> leaders plus the 'class X' or 'void fn(...)' part. */ 'template <...> leaders plus the 'class X' or 'void fn(...)' part. */
static void static void
dump_template_decl (tree t, int flags) dump_template_decl (cxx_pretty_printer *pp, tree t, int flags)
{ {
tree orig_parms = DECL_TEMPLATE_PARMS (t); tree orig_parms = DECL_TEMPLATE_PARMS (t);
tree parms; tree parms;
...@@ -1244,8 +1248,8 @@ dump_template_decl (tree t, int flags) ...@@ -1244,8 +1248,8 @@ dump_template_decl (tree t, int flags)
tree inner_parms = INNERMOST_TEMPLATE_PARMS (parms); tree inner_parms = INNERMOST_TEMPLATE_PARMS (parms);
int len = TREE_VEC_LENGTH (inner_parms); int len = TREE_VEC_LENGTH (inner_parms);
pp_cxx_ws_string (cxx_pp, "template"); pp_cxx_ws_string (pp, "template");
pp_cxx_begin_template_argument_list (cxx_pp); pp_cxx_begin_template_argument_list (pp);
/* If we've shown the template prefix, we'd better show the /* If we've shown the template prefix, we'd better show the
parameters' and decl's type too. */ parameters' and decl's type too. */
...@@ -1254,34 +1258,35 @@ dump_template_decl (tree t, int flags) ...@@ -1254,34 +1258,35 @@ dump_template_decl (tree t, int flags)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
if (i) if (i)
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
dump_template_parameter (TREE_VEC_ELT (inner_parms, i), flags); dump_template_parameter (pp, TREE_VEC_ELT (inner_parms, i),
flags);
} }
pp_cxx_end_template_argument_list (cxx_pp); pp_cxx_end_template_argument_list (pp);
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
} }
nreverse(orig_parms); nreverse(orig_parms);
if (DECL_TEMPLATE_TEMPLATE_PARM_P (t)) if (DECL_TEMPLATE_TEMPLATE_PARM_P (t))
{ {
/* Say `template<arg> class TT' not just `template<arg> TT'. */ /* Say `template<arg> class TT' not just `template<arg> TT'. */
pp_cxx_ws_string (cxx_pp, "class"); pp_cxx_ws_string (pp, "class");
/* If this is a parameter pack, print the ellipsis. */ /* If this is a parameter pack, print the ellipsis. */
if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (t))) if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (t)))
pp_cxx_ws_string (cxx_pp, "..."); pp_cxx_ws_string (pp, "...");
} }
} }
if (DECL_CLASS_TEMPLATE_P (t)) if (DECL_CLASS_TEMPLATE_P (t))
dump_type (TREE_TYPE (t), dump_type (pp, TREE_TYPE (t),
((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME
| (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0))); | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0)));
else if (DECL_TEMPLATE_RESULT (t) else if (DECL_TEMPLATE_RESULT (t)
&& (VAR_P (DECL_TEMPLATE_RESULT (t)) && (VAR_P (DECL_TEMPLATE_RESULT (t))
/* Alias template. */ /* Alias template. */
|| DECL_TYPE_TEMPLATE_P (t))) || DECL_TYPE_TEMPLATE_P (t)))
dump_decl (DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME); dump_decl (pp, DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME);
else else
{ {
gcc_assert (TREE_TYPE (t)); gcc_assert (TREE_TYPE (t));
...@@ -1289,11 +1294,11 @@ dump_template_decl (tree t, int flags) ...@@ -1289,11 +1294,11 @@ dump_template_decl (tree t, int flags)
{ {
case METHOD_TYPE: case METHOD_TYPE:
case FUNCTION_TYPE: case FUNCTION_TYPE:
dump_function_decl (t, flags | TFF_TEMPLATE_NAME); dump_function_decl (pp, t, flags | TFF_TEMPLATE_NAME);
break; break;
default: default:
/* This case can occur with some invalid code. */ /* This case can occur with some invalid code. */
dump_type (TREE_TYPE (t), dump_type (pp, TREE_TYPE (t),
(flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME (flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME
| (flags & TFF_DECL_SPECIFIERS | (flags & TFF_DECL_SPECIFIERS
? TFF_CLASS_KEY_OR_ENUM : 0)); ? TFF_CLASS_KEY_OR_ENUM : 0));
...@@ -1363,7 +1368,7 @@ find_typenames (tree t) ...@@ -1363,7 +1368,7 @@ find_typenames (tree t)
is %D which doesn't print the throw specs, and %F which does. */ is %D which doesn't print the throw specs, and %F which does. */
static void static void
dump_function_decl (tree t, int flags) dump_function_decl (cxx_pretty_printer *pp, tree t, int flags)
{ {
tree fntype; tree fntype;
tree parmtypes; tree parmtypes;
...@@ -1379,7 +1384,7 @@ dump_function_decl (tree t, int flags) ...@@ -1379,7 +1384,7 @@ dump_function_decl (tree t, int flags)
{ {
/* A lambda's signature is essentially its "type", so defer. */ /* A lambda's signature is essentially its "type", so defer. */
gcc_assert (LAMBDA_TYPE_P (DECL_CONTEXT (t))); gcc_assert (LAMBDA_TYPE_P (DECL_CONTEXT (t)));
dump_type (DECL_CONTEXT (t), flags); dump_type (pp, DECL_CONTEXT (t), flags);
return; return;
} }
...@@ -1419,12 +1424,12 @@ dump_function_decl (tree t, int flags) ...@@ -1419,12 +1424,12 @@ dump_function_decl (tree t, int flags)
if (flags & TFF_DECL_SPECIFIERS) if (flags & TFF_DECL_SPECIFIERS)
{ {
if (DECL_STATIC_FUNCTION_P (t)) if (DECL_STATIC_FUNCTION_P (t))
pp_cxx_ws_string (cxx_pp, "static"); pp_cxx_ws_string (pp, "static");
else if (DECL_VIRTUAL_P (t)) else if (DECL_VIRTUAL_P (t))
pp_cxx_ws_string (cxx_pp, "virtual"); pp_cxx_ws_string (pp, "virtual");
if (DECL_DECLARED_CONSTEXPR_P (STRIP_TEMPLATE (t))) if (DECL_DECLARED_CONSTEXPR_P (STRIP_TEMPLATE (t)))
pp_cxx_ws_string (cxx_pp, "constexpr"); pp_cxx_ws_string (pp, "constexpr");
} }
/* Print the return type? */ /* Print the return type? */
...@@ -1434,7 +1439,7 @@ dump_function_decl (tree t, int flags) ...@@ -1434,7 +1439,7 @@ dump_function_decl (tree t, int flags)
if (show_return) if (show_return)
{ {
tree ret = fndecl_declared_return_type (t); tree ret = fndecl_declared_return_type (t);
dump_type_prefix (ret, flags); dump_type_prefix (pp, ret, flags);
} }
/* Print the function name. */ /* Print the function name. */
...@@ -1442,65 +1447,65 @@ dump_function_decl (tree t, int flags) ...@@ -1442,65 +1447,65 @@ dump_function_decl (tree t, int flags)
/* Nothing. */; /* Nothing. */;
else if (cname) else if (cname)
{ {
dump_type (cname, flags); dump_type (pp, cname, flags);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
} }
else else
dump_scope (CP_DECL_CONTEXT (t), flags); dump_scope (pp, CP_DECL_CONTEXT (t), flags);
dump_function_name (t, flags); dump_function_name (pp, t, flags);
if (!(flags & TFF_NO_FUNCTION_ARGUMENTS)) if (!(flags & TFF_NO_FUNCTION_ARGUMENTS))
{ {
dump_parameters (parmtypes, flags); dump_parameters (pp, parmtypes, flags);
if (TREE_CODE (fntype) == METHOD_TYPE) if (TREE_CODE (fntype) == METHOD_TYPE)
{ {
cxx_pp->padding = pp_before; pp->padding = pp_before;
pp_cxx_cv_qualifier_seq (cxx_pp, class_of_this_parm (fntype)); pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (fntype));
dump_ref_qualifier (fntype, flags); dump_ref_qualifier (pp, fntype, flags);
} }
if (flags & TFF_EXCEPTION_SPECIFICATION) if (flags & TFF_EXCEPTION_SPECIFICATION)
{ {
cxx_pp->padding = pp_before; pp->padding = pp_before;
dump_exception_spec (exceptions, flags); dump_exception_spec (pp, exceptions, flags);
} }
if (show_return) if (show_return)
dump_type_suffix (TREE_TYPE (fntype), flags); dump_type_suffix (pp, TREE_TYPE (fntype), flags);
/* If T is a template instantiation, dump the parameter binding. */ /* If T is a template instantiation, dump the parameter binding. */
if (template_parms != NULL_TREE && template_args != NULL_TREE if (template_parms != NULL_TREE && template_args != NULL_TREE
&& !(flags & TFF_NO_TEMPLATE_BINDINGS)) && !(flags & TFF_NO_TEMPLATE_BINDINGS))
{ {
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_bracket (cxx_pp); pp_cxx_left_bracket (pp);
pp_cxx_ws_string (cxx_pp, M_("with")); pp_cxx_ws_string (pp, M_("with"));
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
dump_template_bindings (template_parms, template_args, typenames); dump_template_bindings (pp, template_parms, template_args, typenames);
pp_cxx_right_bracket (cxx_pp); pp_cxx_right_bracket (pp);
} }
} }
else if (template_args) else if (template_args)
{ {
bool need_comma = false; bool need_comma = false;
int i; int i;
pp_cxx_begin_template_argument_list (cxx_pp); pp_cxx_begin_template_argument_list (pp);
template_args = INNERMOST_TEMPLATE_ARGS (template_args); template_args = INNERMOST_TEMPLATE_ARGS (template_args);
for (i = 0; i < TREE_VEC_LENGTH (template_args); ++i) for (i = 0; i < TREE_VEC_LENGTH (template_args); ++i)
{ {
tree arg = TREE_VEC_ELT (template_args, i); tree arg = TREE_VEC_ELT (template_args, i);
if (need_comma) if (need_comma)
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
if (ARGUMENT_PACK_P (arg)) if (ARGUMENT_PACK_P (arg))
pp_cxx_left_brace (cxx_pp); pp_cxx_left_brace (pp);
dump_template_argument (arg, TFF_PLAIN_IDENTIFIER); dump_template_argument (pp, arg, TFF_PLAIN_IDENTIFIER);
if (ARGUMENT_PACK_P (arg)) if (ARGUMENT_PACK_P (arg))
pp_cxx_right_brace (cxx_pp); pp_cxx_right_brace (pp);
need_comma = true; need_comma = true;
} }
pp_cxx_end_template_argument_list (cxx_pp); pp_cxx_end_template_argument_list (pp);
} }
} }
...@@ -1509,84 +1514,84 @@ dump_function_decl (tree t, int flags) ...@@ -1509,84 +1514,84 @@ dump_function_decl (tree t, int flags)
already been removed. */ already been removed. */
static void static void
dump_parameters (tree parmtypes, int flags) dump_parameters (cxx_pretty_printer *pp, tree parmtypes, int flags)
{ {
int first = 1; int first = 1;
flags &= ~TFF_SCOPE; flags &= ~TFF_SCOPE;
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
for (first = 1; parmtypes != void_list_node; for (first = 1; parmtypes != void_list_node;
parmtypes = TREE_CHAIN (parmtypes)) parmtypes = TREE_CHAIN (parmtypes))
{ {
if (!first) if (!first)
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
first = 0; first = 0;
if (!parmtypes) if (!parmtypes)
{ {
pp_cxx_ws_string (cxx_pp, "..."); pp_cxx_ws_string (pp, "...");
break; break;
} }
dump_type (TREE_VALUE (parmtypes), flags); dump_type (pp, TREE_VALUE (parmtypes), flags);
if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && TREE_PURPOSE (parmtypes)) if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && TREE_PURPOSE (parmtypes))
{ {
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_equal (cxx_pp); pp_equal (pp);
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
dump_expr (TREE_PURPOSE (parmtypes), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_PURPOSE (parmtypes), flags | TFF_EXPR_IN_PARENS);
} }
} }
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
/* Print ref-qualifier of a FUNCTION_TYPE or METHOD_TYPE. FLAGS are ignored. */ /* Print ref-qualifier of a FUNCTION_TYPE or METHOD_TYPE. FLAGS are ignored. */
static void static void
dump_ref_qualifier (tree t, int flags ATTRIBUTE_UNUSED) dump_ref_qualifier (cxx_pretty_printer *pp, tree t, int flags ATTRIBUTE_UNUSED)
{ {
if (FUNCTION_REF_QUALIFIED (t)) if (FUNCTION_REF_QUALIFIED (t))
{ {
cxx_pp->padding = pp_before; pp->padding = pp_before;
if (FUNCTION_RVALUE_QUALIFIED (t)) if (FUNCTION_RVALUE_QUALIFIED (t))
pp_cxx_ws_string (cxx_pp, "&&"); pp_cxx_ws_string (pp, "&&");
else else
pp_cxx_ws_string (cxx_pp, "&"); pp_cxx_ws_string (pp, "&");
} }
} }
/* Print an exception specification. T is the exception specification. */ /* Print an exception specification. T is the exception specification. */
static void static void
dump_exception_spec (tree t, int flags) dump_exception_spec (cxx_pretty_printer *pp, tree t, int flags)
{ {
if (t && TREE_PURPOSE (t)) if (t && TREE_PURPOSE (t))
{ {
pp_cxx_ws_string (cxx_pp, "noexcept"); pp_cxx_ws_string (pp, "noexcept");
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
if (DEFERRED_NOEXCEPT_SPEC_P (t)) if (DEFERRED_NOEXCEPT_SPEC_P (t))
pp_cxx_ws_string (cxx_pp, "<uninstantiated>"); pp_cxx_ws_string (pp, "<uninstantiated>");
else else
dump_expr (TREE_PURPOSE (t), flags); dump_expr (pp, TREE_PURPOSE (t), flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
else if (t) else if (t)
{ {
pp_cxx_ws_string (cxx_pp, "throw"); pp_cxx_ws_string (pp, "throw");
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
if (TREE_VALUE (t) != NULL_TREE) if (TREE_VALUE (t) != NULL_TREE)
while (1) while (1)
{ {
dump_type (TREE_VALUE (t), flags); dump_type (pp, TREE_VALUE (t), flags);
t = TREE_CHAIN (t); t = TREE_CHAIN (t);
if (!t) if (!t)
break; break;
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
} }
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
} }
...@@ -1594,7 +1599,7 @@ dump_exception_spec (tree t, int flags) ...@@ -1594,7 +1599,7 @@ dump_exception_spec (tree t, int flags)
and destructors properly. */ and destructors properly. */
static void static void
dump_function_name (tree t, int flags) dump_function_name (cxx_pretty_printer *pp, tree t, int flags)
{ {
tree name = DECL_NAME (t); tree name = DECL_NAME (t);
...@@ -1605,7 +1610,7 @@ dump_function_name (tree t, int flags) ...@@ -1605,7 +1610,7 @@ dump_function_name (tree t, int flags)
literal name. */ literal name. */
if (!DECL_LANG_SPECIFIC (t)) if (!DECL_LANG_SPECIFIC (t))
{ {
pp_cxx_tree_identifier (cxx_pp, name); pp_cxx_tree_identifier (pp, name);
return; return;
} }
...@@ -1626,8 +1631,8 @@ dump_function_name (tree t, int flags) ...@@ -1626,8 +1631,8 @@ dump_function_name (tree t, int flags)
if (DECL_DESTRUCTOR_P (t)) if (DECL_DESTRUCTOR_P (t))
{ {
pp_cxx_complement (cxx_pp); pp_cxx_complement (pp);
dump_decl (name, TFF_PLAIN_IDENTIFIER); dump_decl (pp, name, TFF_PLAIN_IDENTIFIER);
} }
else if (DECL_CONV_FN_P (t)) else if (DECL_CONV_FN_P (t))
{ {
...@@ -1637,21 +1642,22 @@ dump_function_name (tree t, int flags) ...@@ -1637,21 +1642,22 @@ dump_function_name (tree t, int flags)
declarations, both will have the same name, yet declarations, both will have the same name, yet
the types will be different, hence the TREE_TYPE field the types will be different, hence the TREE_TYPE field
of the first name will be clobbered by the second. */ of the first name will be clobbered by the second. */
pp_cxx_ws_string (cxx_pp, "operator"); pp_cxx_ws_string (pp, "operator");
dump_type (TREE_TYPE (TREE_TYPE (t)), flags); dump_type (pp, TREE_TYPE (TREE_TYPE (t)), flags);
} }
else if (name && IDENTIFIER_OPNAME_P (name)) else if (name && IDENTIFIER_OPNAME_P (name))
pp_cxx_tree_identifier (cxx_pp, name); pp_cxx_tree_identifier (pp, name);
else if (name && UDLIT_OPER_P (name)) else if (name && UDLIT_OPER_P (name))
pp_cxx_tree_identifier (cxx_pp, name); pp_cxx_tree_identifier (pp, name);
else else
dump_decl (name, flags); dump_decl (pp, name, flags);
if (DECL_TEMPLATE_INFO (t) if (DECL_TEMPLATE_INFO (t)
&& !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t) && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t)
&& (TREE_CODE (DECL_TI_TEMPLATE (t)) != TEMPLATE_DECL && (TREE_CODE (DECL_TI_TEMPLATE (t)) != TEMPLATE_DECL
|| PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)))) || PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t))))
dump_template_parms (DECL_TEMPLATE_INFO (t), !DECL_USE_TEMPLATE (t), flags); dump_template_parms (pp, DECL_TEMPLATE_INFO (t), !DECL_USE_TEMPLATE (t),
flags);
} }
/* Dump the template parameters from the template info INFO under control of /* Dump the template parameters from the template info INFO under control of
...@@ -1661,14 +1667,15 @@ dump_function_name (tree t, int flags) ...@@ -1661,14 +1667,15 @@ dump_function_name (tree t, int flags)
decoration. */ decoration. */
static void static void
dump_template_parms (tree info, int primary, int flags) dump_template_parms (cxx_pretty_printer *pp, tree info,
int primary, int flags)
{ {
tree args = info ? TI_ARGS (info) : NULL_TREE; tree args = info ? TI_ARGS (info) : NULL_TREE;
if (primary && flags & TFF_TEMPLATE_NAME) if (primary && flags & TFF_TEMPLATE_NAME)
return; return;
flags &= ~(TFF_CLASS_KEY_OR_ENUM | TFF_TEMPLATE_NAME); flags &= ~(TFF_CLASS_KEY_OR_ENUM | TFF_TEMPLATE_NAME);
pp_cxx_begin_template_argument_list (cxx_pp); pp_cxx_begin_template_argument_list (pp);
/* Be careful only to print things when we have them, so as not /* Be careful only to print things when we have them, so as not
to crash producing error messages. */ to crash producing error messages. */
...@@ -1688,12 +1695,12 @@ dump_template_parms (tree info, int primary, int flags) ...@@ -1688,12 +1695,12 @@ dump_template_parms (tree info, int primary, int flags)
if (ix if (ix
&& (!ARGUMENT_PACK_P (arg) && (!ARGUMENT_PACK_P (arg)
|| TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg)) > 0)) || TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg)) > 0))
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
if (!arg) if (!arg)
pp_string (cxx_pp, M_("<template parameter error>")); pp_string (pp, M_("<template parameter error>"));
else else
dump_template_argument (arg, flags); dump_template_argument (pp, arg, flags);
} }
} }
else if (primary) else if (primary)
...@@ -1711,43 +1718,43 @@ dump_template_parms (tree info, int primary, int flags) ...@@ -1711,43 +1718,43 @@ dump_template_parms (tree info, int primary, int flags)
if (TREE_VEC_ELT (parms, ix) == error_mark_node) if (TREE_VEC_ELT (parms, ix) == error_mark_node)
{ {
pp_string (cxx_pp, M_("<template parameter error>")); pp_string (pp, M_("<template parameter error>"));
continue; continue;
} }
parm = TREE_VALUE (TREE_VEC_ELT (parms, ix)); parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
if (ix) if (ix)
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
dump_decl (parm, flags & ~TFF_DECL_SPECIFIERS); dump_decl (pp, parm, flags & ~TFF_DECL_SPECIFIERS);
} }
} }
pp_cxx_end_template_argument_list (cxx_pp); pp_cxx_end_template_argument_list (pp);
} }
/* Print out the arguments of CALL_EXPR T as a parenthesized list using /* Print out the arguments of CALL_EXPR T as a parenthesized list using
flags FLAGS. Skip over the first argument if SKIPFIRST is true. */ flags FLAGS. Skip over the first argument if SKIPFIRST is true. */
static void static void
dump_call_expr_args (tree t, int flags, bool skipfirst) dump_call_expr_args (cxx_pretty_printer *pp, tree t, int flags, bool skipfirst)
{ {
tree arg; tree arg;
call_expr_arg_iterator iter; call_expr_arg_iterator iter;
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
FOR_EACH_CALL_EXPR_ARG (arg, iter, t) FOR_EACH_CALL_EXPR_ARG (arg, iter, t)
{ {
if (skipfirst) if (skipfirst)
skipfirst = false; skipfirst = false;
else else
{ {
dump_expr (arg, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, arg, flags | TFF_EXPR_IN_PARENS);
if (more_call_expr_args_p (&iter)) if (more_call_expr_args_p (&iter))
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
} }
} }
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
/* Print out the arguments of AGGR_INIT_EXPR T as a parenthesized list /* Print out the arguments of AGGR_INIT_EXPR T as a parenthesized list
...@@ -1755,53 +1762,55 @@ dump_call_expr_args (tree t, int flags, bool skipfirst) ...@@ -1755,53 +1762,55 @@ dump_call_expr_args (tree t, int flags, bool skipfirst)
true. */ true. */
static void static void
dump_aggr_init_expr_args (tree t, int flags, bool skipfirst) dump_aggr_init_expr_args (cxx_pretty_printer *pp, tree t, int flags,
bool skipfirst)
{ {
tree arg; tree arg;
aggr_init_expr_arg_iterator iter; aggr_init_expr_arg_iterator iter;
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
FOR_EACH_AGGR_INIT_EXPR_ARG (arg, iter, t) FOR_EACH_AGGR_INIT_EXPR_ARG (arg, iter, t)
{ {
if (skipfirst) if (skipfirst)
skipfirst = false; skipfirst = false;
else else
{ {
dump_expr (arg, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, arg, flags | TFF_EXPR_IN_PARENS);
if (more_aggr_init_expr_args_p (&iter)) if (more_aggr_init_expr_args_p (&iter))
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
} }
} }
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
/* Print out a list of initializers (subr of dump_expr). */ /* Print out a list of initializers (subr of dump_expr). */
static void static void
dump_expr_list (tree l, int flags) dump_expr_list (cxx_pretty_printer *pp, tree l, int flags)
{ {
while (l) while (l)
{ {
dump_expr (TREE_VALUE (l), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_VALUE (l), flags | TFF_EXPR_IN_PARENS);
l = TREE_CHAIN (l); l = TREE_CHAIN (l);
if (l) if (l)
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
} }
} }
/* Print out a vector of initializers (subr of dump_expr). */ /* Print out a vector of initializers (subr of dump_expr). */
static void static void
dump_expr_init_vec (vec<constructor_elt, va_gc> *v, int flags) dump_expr_init_vec (cxx_pretty_printer *pp, vec<constructor_elt, va_gc> *v,
int flags)
{ {
unsigned HOST_WIDE_INT idx; unsigned HOST_WIDE_INT idx;
tree value; tree value;
FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value) FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
{ {
dump_expr (value, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, value, flags | TFF_EXPR_IN_PARENS);
if (idx != v->length () - 1) if (idx != v->length () - 1)
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
} }
} }
...@@ -1830,7 +1839,7 @@ resolve_virtual_fun_from_obj_type_ref (tree ref) ...@@ -1830,7 +1839,7 @@ resolve_virtual_fun_from_obj_type_ref (tree ref)
/* Print out an expression E under control of FLAGS. */ /* Print out an expression E under control of FLAGS. */
static void static void
dump_expr (tree t, int flags) dump_expr (cxx_pretty_printer *pp, tree t, int flags)
{ {
tree op; tree op;
...@@ -1839,7 +1848,7 @@ dump_expr (tree t, int flags) ...@@ -1839,7 +1848,7 @@ dump_expr (tree t, int flags)
if (STATEMENT_CLASS_P (t)) if (STATEMENT_CLASS_P (t))
{ {
pp_cxx_ws_string (cxx_pp, M_("<statement>")); pp_cxx_ws_string (pp, M_("<statement>"));
return; return;
} }
...@@ -1856,70 +1865,70 @@ dump_expr (tree t, int flags) ...@@ -1856,70 +1865,70 @@ dump_expr (tree t, int flags)
case OVERLOAD: case OVERLOAD:
case TYPE_DECL: case TYPE_DECL:
case IDENTIFIER_NODE: case IDENTIFIER_NODE:
dump_decl (t, ((flags & ~(TFF_DECL_SPECIFIERS|TFF_RETURN_TYPE dump_decl (pp, t, ((flags & ~(TFF_DECL_SPECIFIERS|TFF_RETURN_TYPE
|TFF_TEMPLATE_HEADER)) |TFF_TEMPLATE_HEADER))
| TFF_NO_FUNCTION_ARGUMENTS)); | TFF_NO_FUNCTION_ARGUMENTS));
break; break;
case SSA_NAME: case SSA_NAME:
if (SSA_NAME_VAR (t) if (SSA_NAME_VAR (t)
&& !DECL_ARTIFICIAL (SSA_NAME_VAR (t))) && !DECL_ARTIFICIAL (SSA_NAME_VAR (t)))
dump_expr (SSA_NAME_VAR (t), flags); dump_expr (pp, SSA_NAME_VAR (t), flags);
else else
pp_cxx_ws_string (cxx_pp, M_("<unknown>")); pp_cxx_ws_string (pp, M_("<unknown>"));
break; break;
case INTEGER_CST: case INTEGER_CST:
case REAL_CST: case REAL_CST:
case STRING_CST: case STRING_CST:
case COMPLEX_CST: case COMPLEX_CST:
pp_constant (cxx_pp, t); pp_constant (pp, t);
break; break;
case USERDEF_LITERAL: case USERDEF_LITERAL:
pp_cxx_userdef_literal (cxx_pp, t); pp_cxx_userdef_literal (pp, t);
break; break;
case THROW_EXPR: case THROW_EXPR:
/* While waiting for caret diagnostics, avoid printing /* While waiting for caret diagnostics, avoid printing
__cxa_allocate_exception, __cxa_throw, and the like. */ __cxa_allocate_exception, __cxa_throw, and the like. */
pp_cxx_ws_string (cxx_pp, M_("<throw-expression>")); pp_cxx_ws_string (pp, M_("<throw-expression>"));
break; break;
case PTRMEM_CST: case PTRMEM_CST:
pp_ampersand (cxx_pp); pp_ampersand (pp);
dump_type (PTRMEM_CST_CLASS (t), flags); dump_type (pp, PTRMEM_CST_CLASS (t), flags);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
pp_cxx_tree_identifier (cxx_pp, DECL_NAME (PTRMEM_CST_MEMBER (t))); pp_cxx_tree_identifier (pp, DECL_NAME (PTRMEM_CST_MEMBER (t)));
break; break;
case COMPOUND_EXPR: case COMPOUND_EXPR:
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (pp);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case COND_EXPR: case COND_EXPR:
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
pp_string (cxx_pp, " ? "); pp_string (pp, " ? ");
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
pp_string (cxx_pp, " : "); pp_string (pp, " : ");
dump_expr (TREE_OPERAND (t, 2), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 2), flags | TFF_EXPR_IN_PARENS);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case SAVE_EXPR: case SAVE_EXPR:
if (TREE_HAS_CONSTRUCTOR (t)) if (TREE_HAS_CONSTRUCTOR (t))
{ {
pp_cxx_ws_string (cxx_pp, "new"); pp_cxx_ws_string (pp, "new");
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
dump_type (TREE_TYPE (TREE_TYPE (t)), flags); dump_type (pp, TREE_TYPE (TREE_TYPE (t)), flags);
} }
else else
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
break; break;
case AGGR_INIT_EXPR: case AGGR_INIT_EXPR:
...@@ -1932,14 +1941,14 @@ dump_expr (tree t, int flags) ...@@ -1932,14 +1941,14 @@ dump_expr (tree t, int flags)
if (fn && TREE_CODE (fn) == FUNCTION_DECL) if (fn && TREE_CODE (fn) == FUNCTION_DECL)
{ {
if (DECL_CONSTRUCTOR_P (fn)) if (DECL_CONSTRUCTOR_P (fn))
dump_type (DECL_CONTEXT (fn), flags); dump_type (pp, DECL_CONTEXT (fn), flags);
else else
dump_decl (fn, 0); dump_decl (pp, fn, 0);
} }
else else
dump_expr (AGGR_INIT_EXPR_FN (t), 0); dump_expr (pp, AGGR_INIT_EXPR_FN (t), 0);
} }
dump_aggr_init_expr_args (t, flags, true); dump_aggr_init_expr_args (pp, t, flags, true);
break; break;
case CALL_EXPR: case CALL_EXPR:
...@@ -1961,19 +1970,20 @@ dump_expr (tree t, int flags) ...@@ -1961,19 +1970,20 @@ dump_expr (tree t, int flags)
tree ob = CALL_EXPR_ARG (t, 0); tree ob = CALL_EXPR_ARG (t, 0);
if (TREE_CODE (ob) == ADDR_EXPR) if (TREE_CODE (ob) == ADDR_EXPR)
{ {
dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (ob, 0),
pp_cxx_dot (cxx_pp); flags | TFF_EXPR_IN_PARENS);
pp_cxx_dot (pp);
} }
else if (TREE_CODE (ob) != PARM_DECL else if (TREE_CODE (ob) != PARM_DECL
|| strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")) || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
{ {
dump_expr (ob, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
pp_cxx_arrow (cxx_pp); pp_cxx_arrow (pp);
} }
skipfirst = true; skipfirst = true;
} }
dump_expr (fn, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, fn, flags | TFF_EXPR_IN_PARENS);
dump_call_expr_args (t, flags, skipfirst); dump_call_expr_args (pp, t, flags, skipfirst);
} }
break; break;
...@@ -1984,16 +1994,16 @@ dump_expr (tree t, int flags) ...@@ -1984,16 +1994,16 @@ dump_expr (tree t, int flags)
default argument. Note we may have cleared out the first default argument. Note we may have cleared out the first
operand in expand_expr, so don't go killing ourselves. */ operand in expand_expr, so don't go killing ourselves. */
if (TREE_OPERAND (t, 1)) if (TREE_OPERAND (t, 1))
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
break; break;
case POINTER_PLUS_EXPR: case POINTER_PLUS_EXPR:
dump_binary_op ("+", t, flags); dump_binary_op (pp, "+", t, flags);
break; break;
case INIT_EXPR: case INIT_EXPR:
case MODIFY_EXPR: case MODIFY_EXPR:
dump_binary_op (assignment_operator_name_info[(int)NOP_EXPR].name, dump_binary_op (pp, assignment_operator_name_info[NOP_EXPR].name,
t, flags); t, flags);
break; break;
...@@ -2018,20 +2028,20 @@ dump_expr (tree t, int flags) ...@@ -2018,20 +2028,20 @@ dump_expr (tree t, int flags)
case EQ_EXPR: case EQ_EXPR:
case NE_EXPR: case NE_EXPR:
case EXACT_DIV_EXPR: case EXACT_DIV_EXPR:
dump_binary_op (operator_name_info[(int) TREE_CODE (t)].name, t, flags); dump_binary_op (pp, operator_name_info[TREE_CODE (t)].name, t, flags);
break; break;
case CEIL_DIV_EXPR: case CEIL_DIV_EXPR:
case FLOOR_DIV_EXPR: case FLOOR_DIV_EXPR:
case ROUND_DIV_EXPR: case ROUND_DIV_EXPR:
case RDIV_EXPR: case RDIV_EXPR:
dump_binary_op ("/", t, flags); dump_binary_op (pp, "/", t, flags);
break; break;
case CEIL_MOD_EXPR: case CEIL_MOD_EXPR:
case FLOOR_MOD_EXPR: case FLOOR_MOD_EXPR:
case ROUND_MOD_EXPR: case ROUND_MOD_EXPR:
dump_binary_op ("%", t, flags); dump_binary_op (pp, "%", t, flags);
break; break;
case COMPONENT_REF: case COMPONENT_REF:
...@@ -2044,42 +2054,42 @@ dump_expr (tree t, int flags) ...@@ -2044,42 +2054,42 @@ dump_expr (tree t, int flags)
|| (DECL_NAME (ob) || (DECL_NAME (ob)
&& strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))) && strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")))
{ {
dump_expr (ob, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
if (TREE_CODE (TREE_TYPE (ob)) == REFERENCE_TYPE) if (TREE_CODE (TREE_TYPE (ob)) == REFERENCE_TYPE)
pp_cxx_dot (cxx_pp); pp_cxx_dot (pp);
else else
pp_cxx_arrow (cxx_pp); pp_cxx_arrow (pp);
} }
} }
else else
{ {
dump_expr (ob, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
pp_cxx_dot (cxx_pp); pp_cxx_dot (pp);
} }
dump_expr (TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS);
} }
break; break;
case ARRAY_REF: case ARRAY_REF:
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
pp_cxx_left_bracket (cxx_pp); pp_cxx_left_bracket (pp);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
pp_cxx_right_bracket (cxx_pp); pp_cxx_right_bracket (pp);
break; break;
case ARRAY_NOTATION_REF: case ARRAY_NOTATION_REF:
dump_expr (ARRAY_NOTATION_ARRAY (t), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, ARRAY_NOTATION_ARRAY (t), flags | TFF_EXPR_IN_PARENS);
pp_cxx_left_bracket (cxx_pp); pp_cxx_left_bracket (pp);
dump_expr (ARRAY_NOTATION_START (t), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, ARRAY_NOTATION_START (t), flags | TFF_EXPR_IN_PARENS);
pp_colon (cxx_pp); pp_colon (pp);
dump_expr (ARRAY_NOTATION_LENGTH (t), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, ARRAY_NOTATION_LENGTH (t), flags | TFF_EXPR_IN_PARENS);
pp_colon (cxx_pp); pp_colon (pp);
dump_expr (ARRAY_NOTATION_STRIDE (t), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, ARRAY_NOTATION_STRIDE (t), flags | TFF_EXPR_IN_PARENS);
pp_cxx_right_bracket (cxx_pp); pp_cxx_right_bracket (pp);
break; break;
case UNARY_PLUS_EXPR: case UNARY_PLUS_EXPR:
dump_unary_op ("+", t, flags); dump_unary_op (pp, "+", t, flags);
break; break;
case ADDR_EXPR: case ADDR_EXPR:
...@@ -2090,11 +2100,11 @@ dump_expr (tree t, int flags) ...@@ -2090,11 +2100,11 @@ dump_expr (tree t, int flags)
that the expression has pointer type. */ that the expression has pointer type. */
|| (TREE_TYPE (t) || (TREE_TYPE (t)
&& TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)) && TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE))
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
else if (TREE_CODE (TREE_OPERAND (t, 0)) == LABEL_DECL) else if (TREE_CODE (TREE_OPERAND (t, 0)) == LABEL_DECL)
dump_unary_op ("&&", t, flags); dump_unary_op (pp, "&&", t, flags);
else else
dump_unary_op ("&", t, flags); dump_unary_op (pp, "&", t, flags);
break; break;
case INDIRECT_REF: case INDIRECT_REF:
...@@ -2102,44 +2112,45 @@ dump_expr (tree t, int flags) ...@@ -2102,44 +2112,45 @@ dump_expr (tree t, int flags)
{ {
t = TREE_OPERAND (t, 0); t = TREE_OPERAND (t, 0);
gcc_assert (TREE_CODE (t) == CALL_EXPR); gcc_assert (TREE_CODE (t) == CALL_EXPR);
dump_expr (CALL_EXPR_FN (t), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, CALL_EXPR_FN (t), flags | TFF_EXPR_IN_PARENS);
dump_call_expr_args (t, flags, true); dump_call_expr_args (pp, t, flags, true);
} }
else else
{ {
if (TREE_OPERAND (t,0) != NULL_TREE if (TREE_OPERAND (t,0) != NULL_TREE
&& TREE_TYPE (TREE_OPERAND (t, 0)) && TREE_TYPE (TREE_OPERAND (t, 0))
&& NEXT_CODE (TREE_OPERAND (t, 0)) == REFERENCE_TYPE) && NEXT_CODE (TREE_OPERAND (t, 0)) == REFERENCE_TYPE)
dump_expr (TREE_OPERAND (t, 0), flags); dump_expr (pp, TREE_OPERAND (t, 0), flags);
else else
dump_unary_op ("*", t, flags); dump_unary_op (pp, "*", t, flags);
} }
break; break;
case MEM_REF: case MEM_REF:
if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR
&& integer_zerop (TREE_OPERAND (t, 1))) && integer_zerop (TREE_OPERAND (t, 1)))
dump_expr (TREE_OPERAND (TREE_OPERAND (t, 0), 0), flags); dump_expr (pp, TREE_OPERAND (TREE_OPERAND (t, 0), 0), flags);
else else
{ {
pp_cxx_star (cxx_pp); pp_cxx_star (pp);
if (!integer_zerop (TREE_OPERAND (t, 1))) if (!integer_zerop (TREE_OPERAND (t, 1)))
{ {
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
if (!integer_onep (TYPE_SIZE_UNIT if (!integer_onep (TYPE_SIZE_UNIT
(TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0)))))) (TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0))))))
{ {
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_type (ptr_type_node, flags); dump_type (pp, ptr_type_node, flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
} }
dump_expr (TREE_OPERAND (t, 0), flags); dump_expr (pp, TREE_OPERAND (t, 0), flags);
if (!integer_zerop (TREE_OPERAND (t, 1))) if (!integer_zerop (TREE_OPERAND (t, 1)))
{ {
pp_cxx_ws_string (cxx_pp, "+"); pp_cxx_ws_string (pp, "+");
dump_expr (fold_convert (ssizetype, TREE_OPERAND (t, 1)), flags); dump_expr (pp, fold_convert (ssizetype, TREE_OPERAND (t, 1)),
pp_cxx_right_paren (cxx_pp); flags);
pp_cxx_right_paren (pp);
} }
} }
break; break;
...@@ -2149,15 +2160,15 @@ dump_expr (tree t, int flags) ...@@ -2149,15 +2160,15 @@ dump_expr (tree t, int flags)
case TRUTH_NOT_EXPR: case TRUTH_NOT_EXPR:
case PREDECREMENT_EXPR: case PREDECREMENT_EXPR:
case PREINCREMENT_EXPR: case PREINCREMENT_EXPR:
dump_unary_op (operator_name_info [(int)TREE_CODE (t)].name, t, flags); dump_unary_op (pp, operator_name_info [TREE_CODE (t)].name, t, flags);
break; break;
case POSTDECREMENT_EXPR: case POSTDECREMENT_EXPR:
case POSTINCREMENT_EXPR: case POSTINCREMENT_EXPR:
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
pp_cxx_ws_string (cxx_pp, operator_name_info[(int)TREE_CODE (t)].name); pp_cxx_ws_string (pp, operator_name_info[TREE_CODE (t)].name);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case NON_LVALUE_EXPR: case NON_LVALUE_EXPR:
...@@ -2174,16 +2185,16 @@ dump_expr (tree t, int flags) ...@@ -2174,16 +2185,16 @@ dump_expr (tree t, int flags)
if (TREE_CODE (next) == FUNCTION_TYPE) if (TREE_CODE (next) == FUNCTION_TYPE)
{ {
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
pp_cxx_star (cxx_pp); pp_cxx_star (pp);
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
} }
/* Else fall through. */ /* Else fall through. */
} }
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
break; break;
CASE_CONVERT: CASE_CONVERT:
...@@ -2201,25 +2212,25 @@ dump_expr (tree t, int flags) ...@@ -2201,25 +2212,25 @@ dump_expr (tree t, int flags)
TREE_TYPE (ttype))) TREE_TYPE (ttype)))
{ {
if (TREE_CODE (ttype) == REFERENCE_TYPE) if (TREE_CODE (ttype) == REFERENCE_TYPE)
dump_unary_op ("*", t, flags); dump_unary_op (pp, "*", t, flags);
else else
dump_unary_op ("&", t, flags); dump_unary_op (pp, "&", t, flags);
} }
else if (!same_type_p (TREE_TYPE (op), TREE_TYPE (t))) else if (!same_type_p (TREE_TYPE (op), TREE_TYPE (t)))
{ {
/* It is a cast, but we cannot tell whether it is a /* It is a cast, but we cannot tell whether it is a
reinterpret or static cast. Use the C style notation. */ reinterpret or static cast. Use the C style notation. */
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_type (TREE_TYPE (t), flags); dump_type (pp, TREE_TYPE (t), flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
dump_expr (op, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, op, flags | TFF_EXPR_IN_PARENS);
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
else else
dump_expr (op, flags); dump_expr (pp, op, flags);
break; break;
} }
...@@ -2231,12 +2242,12 @@ dump_expr (tree t, int flags) ...@@ -2231,12 +2242,12 @@ dump_expr (tree t, int flags)
if (integer_zerop (idx)) if (integer_zerop (idx))
{ {
/* A NULL pointer-to-member constant. */ /* A NULL pointer-to-member constant. */
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_type (TREE_TYPE (t), flags); dump_type (pp, TREE_TYPE (t), flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
pp_character (cxx_pp, '0'); pp_character (pp, '0');
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
} }
else if (host_integerp (idx, 0)) else if (host_integerp (idx, 0))
...@@ -2261,27 +2272,27 @@ dump_expr (tree t, int flags) ...@@ -2261,27 +2272,27 @@ dump_expr (tree t, int flags)
} }
if (virtuals) if (virtuals)
{ {
dump_expr (BV_FN (virtuals), dump_expr (pp, BV_FN (virtuals),
flags | TFF_EXPR_IN_PARENS); flags | TFF_EXPR_IN_PARENS);
break; break;
} }
} }
} }
if (TREE_TYPE (t) && LAMBDA_TYPE_P (TREE_TYPE (t))) if (TREE_TYPE (t) && LAMBDA_TYPE_P (TREE_TYPE (t)))
pp_string (cxx_pp, "<lambda closure object>"); pp_string (pp, "<lambda closure object>");
if (TREE_TYPE (t) && EMPTY_CONSTRUCTOR_P (t)) if (TREE_TYPE (t) && EMPTY_CONSTRUCTOR_P (t))
{ {
dump_type (TREE_TYPE (t), 0); dump_type (pp, TREE_TYPE (t), 0);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
else else
{ {
if (!BRACE_ENCLOSED_INITIALIZER_P (t)) if (!BRACE_ENCLOSED_INITIALIZER_P (t))
dump_type (TREE_TYPE (t), 0); dump_type (pp, TREE_TYPE (t), 0);
pp_cxx_left_brace (cxx_pp); pp_cxx_left_brace (pp);
dump_expr_init_vec (CONSTRUCTOR_ELTS (t), flags); dump_expr_init_vec (pp, CONSTRUCTOR_ELTS (t), flags);
pp_cxx_right_brace (cxx_pp); pp_cxx_right_brace (pp);
} }
break; break;
...@@ -2294,151 +2305,151 @@ dump_expr (tree t, int flags) ...@@ -2294,151 +2305,151 @@ dump_expr (tree t, int flags)
t = TREE_OPERAND (t, 1); t = TREE_OPERAND (t, 1);
if (TREE_CODE (t) == FUNCTION_DECL) if (TREE_CODE (t) == FUNCTION_DECL)
/* A::f */ /* A::f */
dump_expr (t, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, t, flags | TFF_EXPR_IN_PARENS);
else if (BASELINK_P (t)) else if (BASELINK_P (t))
dump_expr (OVL_CURRENT (BASELINK_FUNCTIONS (t)), dump_expr (pp, OVL_CURRENT (BASELINK_FUNCTIONS (t)),
flags | TFF_EXPR_IN_PARENS); flags | TFF_EXPR_IN_PARENS);
else else
dump_decl (t, flags); dump_decl (pp, t, flags);
} }
else else
{ {
if (INDIRECT_REF_P (ob)) if (INDIRECT_REF_P (ob))
{ {
dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS);
pp_cxx_arrow (cxx_pp); pp_cxx_arrow (pp);
pp_cxx_star (cxx_pp); pp_cxx_star (pp);
} }
else else
{ {
dump_expr (ob, flags | TFF_EXPR_IN_PARENS); dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
pp_cxx_dot (cxx_pp); pp_cxx_dot (pp);
pp_cxx_star (cxx_pp); pp_cxx_star (pp);
} }
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
} }
break; break;
} }
case TEMPLATE_PARM_INDEX: case TEMPLATE_PARM_INDEX:
dump_decl (TEMPLATE_PARM_DECL (t), flags & ~TFF_DECL_SPECIFIERS); dump_decl (pp, TEMPLATE_PARM_DECL (t), flags & ~TFF_DECL_SPECIFIERS);
break; break;
case CAST_EXPR: case CAST_EXPR:
if (TREE_OPERAND (t, 0) == NULL_TREE if (TREE_OPERAND (t, 0) == NULL_TREE
|| TREE_CHAIN (TREE_OPERAND (t, 0))) || TREE_CHAIN (TREE_OPERAND (t, 0)))
{ {
dump_type (TREE_TYPE (t), flags); dump_type (pp, TREE_TYPE (t), flags);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr_list (TREE_OPERAND (t, 0), flags); dump_expr_list (pp, TREE_OPERAND (t, 0), flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
else else
{ {
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_type (TREE_TYPE (t), flags); dump_type (pp, TREE_TYPE (t), flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr_list (TREE_OPERAND (t, 0), flags); dump_expr_list (pp, TREE_OPERAND (t, 0), flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
break; break;
case STATIC_CAST_EXPR: case STATIC_CAST_EXPR:
pp_cxx_ws_string (cxx_pp, "static_cast"); pp_cxx_ws_string (pp, "static_cast");
goto cast; goto cast;
case REINTERPRET_CAST_EXPR: case REINTERPRET_CAST_EXPR:
pp_cxx_ws_string (cxx_pp, "reinterpret_cast"); pp_cxx_ws_string (pp, "reinterpret_cast");
goto cast; goto cast;
case CONST_CAST_EXPR: case CONST_CAST_EXPR:
pp_cxx_ws_string (cxx_pp, "const_cast"); pp_cxx_ws_string (pp, "const_cast");
goto cast; goto cast;
case DYNAMIC_CAST_EXPR: case DYNAMIC_CAST_EXPR:
pp_cxx_ws_string (cxx_pp, "dynamic_cast"); pp_cxx_ws_string (pp, "dynamic_cast");
cast: cast:
pp_cxx_begin_template_argument_list (cxx_pp); pp_cxx_begin_template_argument_list (pp);
dump_type (TREE_TYPE (t), flags); dump_type (pp, TREE_TYPE (t), flags);
pp_cxx_end_template_argument_list (cxx_pp); pp_cxx_end_template_argument_list (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (TREE_OPERAND (t, 0), flags); dump_expr (pp, TREE_OPERAND (t, 0), flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case ARROW_EXPR: case ARROW_EXPR:
dump_expr (TREE_OPERAND (t, 0), flags); dump_expr (pp, TREE_OPERAND (t, 0), flags);
pp_cxx_arrow (cxx_pp); pp_cxx_arrow (pp);
break; break;
case SIZEOF_EXPR: case SIZEOF_EXPR:
case ALIGNOF_EXPR: case ALIGNOF_EXPR:
if (TREE_CODE (t) == SIZEOF_EXPR) if (TREE_CODE (t) == SIZEOF_EXPR)
pp_cxx_ws_string (cxx_pp, "sizeof"); pp_cxx_ws_string (pp, "sizeof");
else else
{ {
gcc_assert (TREE_CODE (t) == ALIGNOF_EXPR); gcc_assert (TREE_CODE (t) == ALIGNOF_EXPR);
pp_cxx_ws_string (cxx_pp, "__alignof__"); pp_cxx_ws_string (pp, "__alignof__");
} }
op = TREE_OPERAND (t, 0); op = TREE_OPERAND (t, 0);
if (PACK_EXPANSION_P (op)) if (PACK_EXPANSION_P (op))
{ {
pp_string (cxx_pp, "..."); pp_string (pp, "...");
op = PACK_EXPANSION_PATTERN (op); op = PACK_EXPANSION_PATTERN (op);
} }
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
if (TREE_CODE (t) == SIZEOF_EXPR && SIZEOF_EXPR_TYPE_P (t)) if (TREE_CODE (t) == SIZEOF_EXPR && SIZEOF_EXPR_TYPE_P (t))
dump_type (TREE_TYPE (op), flags); dump_type (pp, TREE_TYPE (op), flags);
else if (TYPE_P (TREE_OPERAND (t, 0))) else if (TYPE_P (TREE_OPERAND (t, 0)))
dump_type (op, flags); dump_type (pp, op, flags);
else else
dump_expr (op, flags); dump_expr (pp, op, flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case AT_ENCODE_EXPR: case AT_ENCODE_EXPR:
pp_cxx_ws_string (cxx_pp, "@encode"); pp_cxx_ws_string (pp, "@encode");
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_type (TREE_OPERAND (t, 0), flags); dump_type (pp, TREE_OPERAND (t, 0), flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case NOEXCEPT_EXPR: case NOEXCEPT_EXPR:
pp_cxx_ws_string (cxx_pp, "noexcept"); pp_cxx_ws_string (pp, "noexcept");
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (TREE_OPERAND (t, 0), flags); dump_expr (pp, TREE_OPERAND (t, 0), flags);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case REALPART_EXPR: case REALPART_EXPR:
case IMAGPART_EXPR: case IMAGPART_EXPR:
pp_cxx_ws_string (cxx_pp, operator_name_info[TREE_CODE (t)].name); pp_cxx_ws_string (pp, operator_name_info[TREE_CODE (t)].name);
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
dump_expr (TREE_OPERAND (t, 0), flags); dump_expr (pp, TREE_OPERAND (t, 0), flags);
break; break;
case DEFAULT_ARG: case DEFAULT_ARG:
pp_string (cxx_pp, M_("<unparsed>")); pp_string (pp, M_("<unparsed>"));
break; break;
case TRY_CATCH_EXPR: case TRY_CATCH_EXPR:
case WITH_CLEANUP_EXPR: case WITH_CLEANUP_EXPR:
case CLEANUP_POINT_EXPR: case CLEANUP_POINT_EXPR:
dump_expr (TREE_OPERAND (t, 0), flags); dump_expr (pp, TREE_OPERAND (t, 0), flags);
break; break;
case PSEUDO_DTOR_EXPR: case PSEUDO_DTOR_EXPR:
dump_expr (TREE_OPERAND (t, 2), flags); dump_expr (pp, TREE_OPERAND (t, 2), flags);
pp_cxx_dot (cxx_pp); pp_cxx_dot (pp);
dump_type (TREE_OPERAND (t, 0), flags); dump_type (pp, TREE_OPERAND (t, 0), flags);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (pp);
pp_cxx_complement (cxx_pp); pp_cxx_complement (pp);
dump_type (TREE_OPERAND (t, 1), flags); dump_type (pp, TREE_OPERAND (t, 1), flags);
break; break;
case TEMPLATE_ID_EXPR: case TEMPLATE_ID_EXPR:
dump_decl (t, flags); dump_decl (pp, t, flags);
break; break;
case BIND_EXPR: case BIND_EXPR:
...@@ -2447,37 +2458,37 @@ dump_expr (tree t, int flags) ...@@ -2447,37 +2458,37 @@ dump_expr (tree t, int flags)
case STATEMENT_LIST: case STATEMENT_LIST:
/* We don't yet have a way of dumping statements in a /* We don't yet have a way of dumping statements in a
human-readable format. */ human-readable format. */
pp_string (cxx_pp, "({...})"); pp_string (pp, "({...})");
break; break;
case LOOP_EXPR: case LOOP_EXPR:
pp_string (cxx_pp, "while (1) { "); pp_string (pp, "while (1) { ");
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
pp_cxx_right_brace (cxx_pp); pp_cxx_right_brace (pp);
break; break;
case EXIT_EXPR: case EXIT_EXPR:
pp_string (cxx_pp, "if ("); pp_string (pp, "if (");
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
pp_string (cxx_pp, ") break; "); pp_string (pp, ") break; ");
break; break;
case BASELINK: case BASELINK:
dump_expr (BASELINK_FUNCTIONS (t), flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, BASELINK_FUNCTIONS (t), flags & ~TFF_EXPR_IN_PARENS);
break; break;
case EMPTY_CLASS_EXPR: case EMPTY_CLASS_EXPR:
dump_type (TREE_TYPE (t), flags); dump_type (pp, TREE_TYPE (t), flags);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case NON_DEPENDENT_EXPR: case NON_DEPENDENT_EXPR:
dump_expr (TREE_OPERAND (t, 0), flags); dump_expr (pp, TREE_OPERAND (t, 0), flags);
break; break;
case ARGUMENT_PACK_SELECT: case ARGUMENT_PACK_SELECT:
dump_template_argument (ARGUMENT_PACK_SELECT_FROM_PACK (t), flags); dump_template_argument (pp, ARGUMENT_PACK_SELECT_FROM_PACK (t), flags);
break; break;
case RECORD_TYPE: case RECORD_TYPE:
...@@ -2489,35 +2500,35 @@ dump_expr (tree t, int flags) ...@@ -2489,35 +2500,35 @@ dump_expr (tree t, int flags)
case INTEGER_TYPE: case INTEGER_TYPE:
case COMPLEX_TYPE: case COMPLEX_TYPE:
case VECTOR_TYPE: case VECTOR_TYPE:
pp_type_specifier_seq (cxx_pp, t); pp_type_specifier_seq (pp, t);
break; break;
case TYPENAME_TYPE: case TYPENAME_TYPE:
/* We get here when we want to print a dependent type as an /* We get here when we want to print a dependent type as an
id-expression, without any disambiguator decoration. */ id-expression, without any disambiguator decoration. */
pp_id_expression (cxx_pp, t); pp_id_expression (pp, t);
break; break;
case TEMPLATE_TYPE_PARM: case TEMPLATE_TYPE_PARM:
case TEMPLATE_TEMPLATE_PARM: case TEMPLATE_TEMPLATE_PARM:
case BOUND_TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM:
dump_type (t, flags); dump_type (pp, t, flags);
break; break;
case TRAIT_EXPR: case TRAIT_EXPR:
pp_cxx_trait_expression (cxx_pp, t); pp_cxx_trait_expression (pp, t);
break; break;
case VA_ARG_EXPR: case VA_ARG_EXPR:
pp_cxx_va_arg_expression (cxx_pp, t); pp_cxx_va_arg_expression (pp, t);
break; break;
case OFFSETOF_EXPR: case OFFSETOF_EXPR:
pp_cxx_offsetof_expression (cxx_pp, t); pp_cxx_offsetof_expression (pp, t);
break; break;
case SCOPE_REF: case SCOPE_REF:
dump_decl (t, flags); dump_decl (pp, t, flags);
break; break;
case EXPR_PACK_EXPANSION: case EXPR_PACK_EXPANSION:
...@@ -2545,69 +2556,70 @@ dump_expr (tree t, int flags) ...@@ -2545,69 +2556,70 @@ dump_expr (tree t, int flags)
case BIT_FIELD_REF: case BIT_FIELD_REF:
case FIX_TRUNC_EXPR: case FIX_TRUNC_EXPR:
case FLOAT_EXPR: case FLOAT_EXPR:
pp_expression (cxx_pp, t); pp_expression (pp, t);
break; break;
case TRUTH_AND_EXPR: case TRUTH_AND_EXPR:
case TRUTH_OR_EXPR: case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR: case TRUTH_XOR_EXPR:
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
pp_expression (cxx_pp, t); pp_expression (pp, t);
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
case OBJ_TYPE_REF: case OBJ_TYPE_REF:
dump_expr (resolve_virtual_fun_from_obj_type_ref (t), flags); dump_expr (pp, resolve_virtual_fun_from_obj_type_ref (t), flags);
break; break;
case LAMBDA_EXPR: case LAMBDA_EXPR:
pp_string (cxx_pp, M_("<lambda>")); pp_string (pp, M_("<lambda>"));
break; break;
case PAREN_EXPR: case PAREN_EXPR:
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
break; break;
/* This list is incomplete, but should suffice for now. /* This list is incomplete, but should suffice for now.
It is very important that `sorry' does not call It is very important that `sorry' does not call
`report_error_function'. That could cause an infinite loop. */ `report_error_function'. That could cause an infinite loop. */
default: default:
pp_unsupported_tree (cxx_pp, t); pp_unsupported_tree (pp, t);
/* fall through to ERROR_MARK... */ /* fall through to ERROR_MARK... */
case ERROR_MARK: case ERROR_MARK:
pp_string (cxx_pp, M_("<expression error>")); pp_string (pp, M_("<expression error>"));
break; break;
} }
} }
static void static void
dump_binary_op (const char *opstring, tree t, int flags) dump_binary_op (cxx_pretty_printer *pp, const char *opstring, tree t,
int flags)
{ {
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
if (opstring) if (opstring)
pp_cxx_ws_string (cxx_pp, opstring); pp_cxx_ws_string (pp, opstring);
else else
pp_string (cxx_pp, M_("<unknown operator>")); pp_string (pp, M_("<unknown operator>"));
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (pp);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
static void static void
dump_unary_op (const char *opstring, tree t, int flags) dump_unary_op (cxx_pretty_printer *pp, const char *opstring, tree t, int flags)
{ {
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (pp);
pp_cxx_ws_string (cxx_pp, opstring); pp_cxx_ws_string (pp, opstring);
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS); dump_expr (pp, TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_right_paren (cxx_pp); pp_cxx_right_paren (pp);
} }
static void static void
...@@ -2629,7 +2641,7 @@ type_as_string (tree typ, int flags) ...@@ -2629,7 +2641,7 @@ type_as_string (tree typ, int flags)
{ {
reinit_cxx_pp (); reinit_cxx_pp ();
pp_translate_identifiers (cxx_pp) = false; pp_translate_identifiers (cxx_pp) = false;
dump_type (typ, flags); dump_type (cxx_pp, typ, flags);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2637,7 +2649,7 @@ const char * ...@@ -2637,7 +2649,7 @@ const char *
type_as_string_translate (tree typ, int flags) type_as_string_translate (tree typ, int flags)
{ {
reinit_cxx_pp (); reinit_cxx_pp ();
dump_type (typ, flags); dump_type (cxx_pp, typ, flags);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2646,7 +2658,7 @@ expr_as_string (tree decl, int flags) ...@@ -2646,7 +2658,7 @@ expr_as_string (tree decl, int flags)
{ {
reinit_cxx_pp (); reinit_cxx_pp ();
pp_translate_identifiers (cxx_pp) = false; pp_translate_identifiers (cxx_pp) = false;
dump_expr (decl, flags); dump_expr (cxx_pp, decl, flags);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2670,7 +2682,7 @@ decl_as_string (tree decl, int flags) ...@@ -2670,7 +2682,7 @@ decl_as_string (tree decl, int flags)
{ {
reinit_cxx_pp (); reinit_cxx_pp ();
pp_translate_identifiers (cxx_pp) = false; pp_translate_identifiers (cxx_pp) = false;
dump_decl (decl, flags); dump_decl (cxx_pp, decl, flags);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2678,7 +2690,7 @@ const char * ...@@ -2678,7 +2690,7 @@ const char *
decl_as_string_translate (tree decl, int flags) decl_as_string_translate (tree decl, int flags)
{ {
reinit_cxx_pp (); reinit_cxx_pp ();
dump_decl (decl, flags); dump_decl (cxx_pp, decl, flags);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2714,17 +2726,17 @@ lang_decl_name (tree decl, int v, bool translate) ...@@ -2714,17 +2726,17 @@ lang_decl_name (tree decl, int v, bool translate)
|| (DECL_NAMESPACE_SCOPE_P (decl) || (DECL_NAMESPACE_SCOPE_P (decl)
&& CP_DECL_CONTEXT (decl) != global_namespace))) && CP_DECL_CONTEXT (decl) != global_namespace)))
{ {
dump_type (CP_DECL_CONTEXT (decl), TFF_PLAIN_IDENTIFIER); dump_type (cxx_pp, CP_DECL_CONTEXT (decl), TFF_PLAIN_IDENTIFIER);
pp_cxx_colon_colon (cxx_pp); pp_cxx_colon_colon (cxx_pp);
} }
if (TREE_CODE (decl) == FUNCTION_DECL) if (TREE_CODE (decl) == FUNCTION_DECL)
dump_function_name (decl, TFF_PLAIN_IDENTIFIER); dump_function_name (cxx_pp, decl, TFF_PLAIN_IDENTIFIER);
else if ((DECL_NAME (decl) == NULL_TREE) else if ((DECL_NAME (decl) == NULL_TREE)
&& TREE_CODE (decl) == NAMESPACE_DECL) && TREE_CODE (decl) == NAMESPACE_DECL)
dump_decl (decl, TFF_PLAIN_IDENTIFIER | TFF_UNQUALIFIED_NAME); dump_decl (cxx_pp, decl, TFF_PLAIN_IDENTIFIER | TFF_UNQUALIFIED_NAME);
else else
dump_decl (DECL_NAME (decl), TFF_PLAIN_IDENTIFIER); dump_decl (cxx_pp, DECL_NAME (decl), TFF_PLAIN_IDENTIFIER);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2769,7 +2781,7 @@ decl_to_string (tree decl, int verbose) ...@@ -2769,7 +2781,7 @@ decl_to_string (tree decl, int verbose)
flags |= TFF_TEMPLATE_HEADER; flags |= TFF_TEMPLATE_HEADER;
reinit_cxx_pp (); reinit_cxx_pp ();
dump_decl (decl, flags); dump_decl (cxx_pp, decl, flags);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2777,7 +2789,7 @@ static const char * ...@@ -2777,7 +2789,7 @@ static const char *
expr_to_string (tree decl) expr_to_string (tree decl)
{ {
reinit_cxx_pp (); reinit_cxx_pp ();
dump_expr (decl, 0); dump_expr (cxx_pp, decl, 0);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2791,7 +2803,7 @@ fndecl_to_string (tree fndecl, int verbose) ...@@ -2791,7 +2803,7 @@ fndecl_to_string (tree fndecl, int verbose)
if (verbose) if (verbose)
flags |= TFF_FUNCTION_DEFAULT_ARGUMENTS; flags |= TFF_FUNCTION_DEFAULT_ARGUMENTS;
reinit_cxx_pp (); reinit_cxx_pp ();
dump_decl (fndecl, flags); dump_decl (cxx_pp, fndecl, flags);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2838,7 +2850,7 @@ parm_to_string (int p) ...@@ -2838,7 +2850,7 @@ parm_to_string (int p)
static const char * static const char *
op_to_string (enum tree_code p) op_to_string (enum tree_code p)
{ {
tree id = operator_name_info[(int) p].identifier; tree id = operator_name_info[p].identifier;
return id ? IDENTIFIER_POINTER (id) : M_("<unknown>"); return id ? IDENTIFIER_POINTER (id) : M_("<unknown>");
} }
...@@ -2851,7 +2863,7 @@ type_to_string (tree typ, int verbose) ...@@ -2851,7 +2863,7 @@ type_to_string (tree typ, int verbose)
flags |= TFF_TEMPLATE_HEADER; flags |= TFF_TEMPLATE_HEADER;
reinit_cxx_pp (); reinit_cxx_pp ();
dump_type (typ, flags); dump_type (cxx_pp, typ, flags);
/* If we're printing a type that involves typedefs, also print the /* If we're printing a type that involves typedefs, also print the
stripped version. But sometimes the stripped version looks stripped version. But sometimes the stripped version looks
exactly the same, so we don't want it after all. To avoid printing exactly the same, so we don't want it after all. To avoid printing
...@@ -2868,7 +2880,7 @@ type_to_string (tree typ, int verbose) ...@@ -2868,7 +2880,7 @@ type_to_string (tree typ, int verbose)
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (cxx_pp);
/* And remember the start of the aka dump. */ /* And remember the start of the aka dump. */
aka_start = obstack_object_size (ob); aka_start = obstack_object_size (ob);
dump_type (aka, flags); dump_type (cxx_pp, aka, flags);
pp_right_brace (cxx_pp); pp_right_brace (cxx_pp);
p = (char*)obstack_base (ob); p = (char*)obstack_base (ob);
/* If they are identical, cut off the aka with a NUL. */ /* If they are identical, cut off the aka with a NUL. */
...@@ -2904,7 +2916,7 @@ args_to_string (tree p, int verbose) ...@@ -2904,7 +2916,7 @@ args_to_string (tree p, int verbose)
if (TREE_VALUE (p) == null_node) if (TREE_VALUE (p) == null_node)
pp_cxx_ws_string (cxx_pp, "NULL"); pp_cxx_ws_string (cxx_pp, "NULL");
else else
dump_type (error_type (TREE_VALUE (p)), flags); dump_type (cxx_pp, error_type (TREE_VALUE (p)), flags);
if (TREE_CHAIN (p)) if (TREE_CHAIN (p))
pp_separate_with_comma (cxx_pp); pp_separate_with_comma (cxx_pp);
} }
...@@ -2928,12 +2940,12 @@ subst_to_string (tree p) ...@@ -2928,12 +2940,12 @@ subst_to_string (tree p)
return ""; return "";
reinit_cxx_pp (); reinit_cxx_pp ();
dump_template_decl (TREE_PURPOSE (p), flags); dump_template_decl (cxx_pp, TREE_PURPOSE (p), flags);
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (cxx_pp);
pp_cxx_left_bracket (cxx_pp); pp_cxx_left_bracket (cxx_pp);
pp_cxx_ws_string (cxx_pp, M_("with")); pp_cxx_ws_string (cxx_pp, M_("with"));
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (cxx_pp);
dump_template_bindings (tparms, targs, NULL); dump_template_bindings (cxx_pp, tparms, targs, NULL);
pp_cxx_right_bracket (cxx_pp); pp_cxx_right_bracket (cxx_pp);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment