From 3c1ab1ab837e235a763d858cbd18e7fac16f3bc7 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Sat, 17 Aug 2013 20:31:02 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 32 ++ gcc/cp/error.c | 1270 +++++++++++++++++++++++++++--------------------------- 2 files changed, 673 insertions(+), 629 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 502eecb..7ada1ae 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,35 @@ +2013-08-17 Gabriel Dos Reis + + * 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 PR c++/51912 diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 440169a..5741b17 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -59,33 +59,34 @@ static const char *op_to_string (enum tree_code); static const char *parm_to_string (int); static const char *type_to_string (tree, int); -static void dump_alias_template_specialization (tree, int); -static void dump_type (tree, int); -static void dump_typename (tree, int); -static void dump_simple_decl (tree, tree, int); -static void dump_decl (tree, int); -static void dump_template_decl (tree, int); -static void dump_function_decl (tree, int); -static void dump_expr (tree, int); -static void dump_unary_op (const char *, tree, int); -static void dump_binary_op (const char *, tree, int); -static void dump_aggr_type (tree, int); -static void dump_type_prefix (tree, int); -static void dump_type_suffix (tree, int); -static void dump_function_name (tree, int); -static void dump_call_expr_args (tree, int, bool); -static void dump_aggr_init_expr_args (tree, int, bool); -static void dump_expr_list (tree, int); -static void dump_global_iord (tree); -static void dump_parameters (tree, int); -static void dump_ref_qualifier (tree, int); -static void dump_exception_spec (tree, int); -static void dump_template_argument (tree, int); -static void dump_template_argument_list (tree, int); -static void dump_template_parameter (tree, int); -static void dump_template_bindings (tree, tree, vec *); -static void dump_scope (tree, int); -static void dump_template_parms (tree, int, int); +static void dump_alias_template_specialization (cxx_pretty_printer *, tree, int); +static void dump_type (cxx_pretty_printer *, tree, int); +static void dump_typename (cxx_pretty_printer *, tree, int); +static void dump_simple_decl (cxx_pretty_printer *, tree, tree, int); +static void dump_decl (cxx_pretty_printer *, tree, int); +static void dump_template_decl (cxx_pretty_printer *, tree, int); +static void dump_function_decl (cxx_pretty_printer *, tree, int); +static void dump_expr (cxx_pretty_printer *, tree, int); +static void dump_unary_op (cxx_pretty_printer *, const char *, tree, int); +static void dump_binary_op (cxx_pretty_printer *, const char *, tree, int); +static void dump_aggr_type (cxx_pretty_printer *, tree, int); +static void dump_type_prefix (cxx_pretty_printer *, tree, int); +static void dump_type_suffix (cxx_pretty_printer *, tree, int); +static void dump_function_name (cxx_pretty_printer *, tree, int); +static void dump_call_expr_args (cxx_pretty_printer *, tree, int, bool); +static void dump_aggr_init_expr_args (cxx_pretty_printer *, tree, int, bool); +static void dump_expr_list (cxx_pretty_printer *, tree, int); +static void dump_global_iord (cxx_pretty_printer *, tree); +static void dump_parameters (cxx_pretty_printer *, tree, int); +static void dump_ref_qualifier (cxx_pretty_printer *, tree, int); +static void dump_exception_spec (cxx_pretty_printer *, tree, int); +static void dump_template_argument (cxx_pretty_printer *, tree, int); +static void dump_template_argument_list (cxx_pretty_printer *, tree, int); +static void dump_template_parameter (cxx_pretty_printer *, tree, int); +static void dump_template_bindings (cxx_pretty_printer *, tree, tree, + vec *); +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 const char *function_category (tree); static void maybe_print_constexpr_context (diagnostic_context *); @@ -115,7 +116,7 @@ init_error (void) /* Dump a scope, if deemed necessary. */ 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); @@ -126,39 +127,39 @@ dump_scope (tree scope, int flags) { if (scope != global_namespace) { - dump_decl (scope, f); - pp_cxx_colon_colon (cxx_pp); + dump_decl (pp, scope, f); + pp_cxx_colon_colon (pp); } } else if (AGGREGATE_TYPE_P (scope)) { - dump_type (scope, f); - pp_cxx_colon_colon (cxx_pp); + dump_type (pp, scope, f); + pp_cxx_colon_colon (pp); } else if ((flags & TFF_SCOPE) && TREE_CODE (scope) == FUNCTION_DECL) { - dump_function_decl (scope, f); - pp_cxx_colon_colon (cxx_pp); + dump_function_decl (pp, scope, f); + pp_cxx_colon_colon (pp); } } /* Dump the template ARGument under control of FLAGS. */ 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)) - dump_template_argument_list (ARGUMENT_PACK_ARGS (arg), + dump_template_argument_list (pp, ARGUMENT_PACK_ARGS (arg), /* No default args in argument packs. */ flags|TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS); 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 { if (TREE_CODE (arg) == TREE_LIST) 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) of FLAGS. */ 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 need_comma = 0; @@ -202,9 +203,9 @@ dump_template_argument_list (tree args, int flags) if (need_comma && (!ARGUMENT_PACK_P (arg) || 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; } } @@ -212,7 +213,7 @@ dump_template_argument_list (tree args, int flags) /* Dump a template parameter PARM (a TREE_LIST) under control of FLAGS. */ static void -dump_template_parameter (tree parm, int flags) +dump_template_parameter (cxx_pretty_printer *pp, tree parm, int flags) { tree p; tree a; @@ -227,29 +228,29 @@ dump_template_parameter (tree parm, int flags) { 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))) - pp_cxx_ws_string (cxx_pp, "..."); + pp_cxx_ws_string (pp, "..."); 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)) - pp_cxx_tree_identifier (cxx_pp, DECL_NAME (p)); + pp_cxx_tree_identifier (pp, DECL_NAME (p)); else - pp_cxx_canonical_template_parameter (cxx_pp, TREE_TYPE (p)); + pp_cxx_canonical_template_parameter (pp, TREE_TYPE (p)); } 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) { - pp_cxx_whitespace (cxx_pp); - pp_equal (cxx_pp); - pp_cxx_whitespace (cxx_pp); + pp_cxx_whitespace (pp); + pp_equal (pp); + pp_cxx_whitespace (pp); 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 - 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) TREE_VEC. */ static void -dump_template_bindings (tree parms, tree args, vec *typenames) +dump_template_bindings (cxx_pretty_printer *pp, tree parms, tree args, + vec *typenames) { bool need_semicolon = false; int i; @@ -285,21 +287,22 @@ dump_template_bindings (tree parms, tree args, vec *typenames) arg = TREE_VEC_ELT (lvl_args, arg_idx); if (need_semicolon) - pp_separate_with_semicolon (cxx_pp); - dump_template_parameter (TREE_VEC_ELT (p, i), TFF_PLAIN_IDENTIFIER); - pp_cxx_whitespace (cxx_pp); - pp_equal (cxx_pp); - pp_cxx_whitespace (cxx_pp); + pp_separate_with_semicolon (pp); + dump_template_parameter (pp, TREE_VEC_ELT (p, i), + TFF_PLAIN_IDENTIFIER); + pp_cxx_whitespace (pp); + pp_equal (pp); + pp_cxx_whitespace (pp); if (arg) { if (ARGUMENT_PACK_P (arg)) - pp_cxx_left_brace (cxx_pp); - dump_template_argument (arg, TFF_PLAIN_IDENTIFIER); + pp_cxx_left_brace (pp); + dump_template_argument (pp, arg, TFF_PLAIN_IDENTIFIER); if (ARGUMENT_PACK_P (arg)) - pp_cxx_right_brace (cxx_pp); + pp_cxx_right_brace (pp); } else - pp_string (cxx_pp, M_("")); + pp_string (pp, M_("")); ++arg_idx; need_semicolon = true; @@ -315,18 +318,18 @@ dump_template_bindings (tree parms, tree args, vec *typenames) FOR_EACH_VEC_SAFE_ELT (typenames, i, t) { if (need_semicolon) - pp_separate_with_semicolon (cxx_pp); - dump_type (t, TFF_PLAIN_IDENTIFIER); - pp_cxx_whitespace (cxx_pp); - pp_equal (cxx_pp); - pp_cxx_whitespace (cxx_pp); + pp_separate_with_semicolon (pp); + dump_type (pp, t, TFF_PLAIN_IDENTIFIER); + pp_cxx_whitespace (pp); + pp_equal (pp); + pp_cxx_whitespace (pp); push_deferring_access_checks (dk_no_check); t = tsubst (t, args, tf_none, NULL_TREE); pop_deferring_access_checks (); /* Strip typedefs. We can't just use TFF_CHASE_TYPEDEF because pp_simple_type_specifier doesn't know about it. */ 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 *typenames) specialization of T. */ static void -dump_alias_template_specialization (tree t, int flags) +dump_alias_template_specialization (cxx_pretty_printer *pp, tree t, int flags) { tree name; gcc_assert (alias_template_specialization_p (t)); 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); - pp_cxx_tree_identifier (cxx_pp, name); - dump_template_parms (TYPE_TEMPLATE_INFO (t), + pp_cxx_tree_identifier (pp, name); + dump_template_parms (pp, TYPE_TEMPLATE_INFO (t), /*primary=*/false, flags & ~TFF_TEMPLATE_HEADER); } @@ -353,7 +356,7 @@ dump_alias_template_specialization (tree t, int flags) format. */ static void -dump_type (tree t, int flags) +dump_type (cxx_pretty_printer *pp, tree t, int flags) { if (t == NULL_TREE) return; @@ -369,15 +372,15 @@ dump_type (tree t, int flags) t = strip_typedefs (t); else if (alias_template_specialization_p (t)) { - dump_alias_template_specialization (t, flags); + dump_alias_template_specialization (pp, t, flags); return; } else if (same_type_p (t, TREE_TYPE (decl))) t = decl; else { - pp_cxx_cv_qualifier_seq (cxx_pp, t); - pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); + pp_cxx_cv_qualifier_seq (pp, t); + pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t)); return; } } @@ -389,39 +392,39 @@ dump_type (tree t, int flags) { case LANG_TYPE: if (t == init_list_type_node) - pp_string (cxx_pp, M_("")); + pp_string (pp, M_("")); else if (t == unknown_type_node) - pp_string (cxx_pp, M_("")); + pp_string (pp, M_("")); else { - pp_cxx_cv_qualifier_seq (cxx_pp, t); - pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); + pp_cxx_cv_qualifier_seq (pp, t); + pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t)); } break; case TREE_LIST: /* A list of function parms. */ - dump_parameters (t, flags); + dump_parameters (pp, t, flags); break; case IDENTIFIER_NODE: - pp_cxx_tree_identifier (cxx_pp, t); + pp_cxx_tree_identifier (pp, t); break; case TREE_BINFO: - dump_type (BINFO_TYPE (t), flags); + dump_type (pp, BINFO_TYPE (t), flags); break; case RECORD_TYPE: case UNION_TYPE: case ENUMERAL_TYPE: - dump_aggr_type (t, flags); + dump_aggr_type (pp, t, flags); break; case TYPE_DECL: 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); break; } @@ -429,7 +432,7 @@ dump_type (tree t, int flags) case TEMPLATE_DECL: case NAMESPACE_DECL: - dump_decl (t, flags & ~TFF_DECL_SPECIFIERS); + dump_decl (pp, t, flags & ~TFF_DECL_SPECIFIERS); break; case INTEGER_TYPE: @@ -439,35 +442,35 @@ dump_type (tree t, int flags) case COMPLEX_TYPE: case VECTOR_TYPE: case FIXED_POINT_TYPE: - pp_type_specifier_seq (cxx_pp, t); + pp_type_specifier_seq (pp, t); break; case TEMPLATE_TEMPLATE_PARM: /* For parameters inside template signature. */ if (TYPE_IDENTIFIER (t)) - pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); + pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t)); else - pp_cxx_canonical_template_parameter (cxx_pp, t); + pp_cxx_canonical_template_parameter (pp, t); break; case BOUND_TEMPLATE_TEMPLATE_PARM: { tree args = TYPE_TI_ARGS (t); - pp_cxx_cv_qualifier_seq (cxx_pp, t); - pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); - pp_cxx_begin_template_argument_list (cxx_pp); - dump_template_argument_list (args, flags); - pp_cxx_end_template_argument_list (cxx_pp); + pp_cxx_cv_qualifier_seq (pp, t); + pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t)); + pp_cxx_begin_template_argument_list (pp); + dump_template_argument_list (pp, args, flags); + pp_cxx_end_template_argument_list (pp); } break; case TEMPLATE_TYPE_PARM: - pp_cxx_cv_qualifier_seq (cxx_pp, t); + pp_cxx_cv_qualifier_seq (pp, t); if (TYPE_IDENTIFIER (t)) - pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); + pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t)); else pp_cxx_canonical_template_parameter - (cxx_pp, TEMPLATE_TYPE_PARM_INDEX (t)); + (pp, TEMPLATE_TYPE_PARM_INDEX (t)); break; /* This is not always necessary for pointers and such, but doing this @@ -480,78 +483,78 @@ dump_type (tree t, int flags) case FUNCTION_TYPE: case METHOD_TYPE: { - dump_type_prefix (t, flags); - dump_type_suffix (t, flags); + dump_type_prefix (pp, t, flags); + dump_type_suffix (pp, t, flags); break; } case TYPENAME_TYPE: if (! (flags & TFF_CHASE_TYPEDEF) && DECL_ORIGINAL_TYPE (TYPE_NAME (t))) { - dump_decl (TYPE_NAME (t), TFF_PLAIN_IDENTIFIER); + dump_decl (pp, TYPE_NAME (t), TFF_PLAIN_IDENTIFIER); break; } - pp_cxx_cv_qualifier_seq (cxx_pp, t); - pp_cxx_ws_string (cxx_pp, + pp_cxx_cv_qualifier_seq (pp, t); + pp_cxx_ws_string (pp, TYPENAME_IS_ENUM_P (t) ? "enum" : TYPENAME_IS_CLASS_P (t) ? "class" : "typename"); - dump_typename (t, flags); + dump_typename (pp, t, flags); break; case UNBOUND_CLASS_TEMPLATE: if (! (flags & TFF_UNQUALIFIED_NAME)) { - dump_type (TYPE_CONTEXT (t), flags); - pp_cxx_colon_colon (cxx_pp); + dump_type (pp, TYPE_CONTEXT (t), flags); + pp_cxx_colon_colon (pp); } - pp_cxx_ws_string (cxx_pp, "template"); - dump_type (DECL_NAME (TYPE_NAME (t)), flags); + pp_cxx_ws_string (pp, "template"); + dump_type (pp, DECL_NAME (TYPE_NAME (t)), flags); break; case TYPEOF_TYPE: - pp_cxx_ws_string (cxx_pp, "__typeof__"); - pp_cxx_whitespace (cxx_pp); - pp_cxx_left_paren (cxx_pp); - dump_expr (TYPEOF_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS); - pp_cxx_right_paren (cxx_pp); + pp_cxx_ws_string (pp, "__typeof__"); + pp_cxx_whitespace (pp); + pp_cxx_left_paren (pp); + dump_expr (pp, TYPEOF_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS); + pp_cxx_right_paren (pp); break; case UNDERLYING_TYPE: - pp_cxx_ws_string (cxx_pp, "__underlying_type"); - pp_cxx_whitespace (cxx_pp); - pp_cxx_left_paren (cxx_pp); - dump_expr (UNDERLYING_TYPE_TYPE (t), flags & ~TFF_EXPR_IN_PARENS); - pp_cxx_right_paren (cxx_pp); + pp_cxx_ws_string (pp, "__underlying_type"); + pp_cxx_whitespace (pp); + pp_cxx_left_paren (pp); + dump_expr (pp, UNDERLYING_TYPE_TYPE (t), flags & ~TFF_EXPR_IN_PARENS); + pp_cxx_right_paren (pp); break; case TYPE_PACK_EXPANSION: - dump_type (PACK_EXPANSION_PATTERN (t), flags); - pp_cxx_ws_string (cxx_pp, "..."); + dump_type (pp, PACK_EXPANSION_PATTERN (t), flags); + pp_cxx_ws_string (pp, "..."); break; case TYPE_ARGUMENT_PACK: - dump_template_argument (t, flags); + dump_template_argument (pp, t, flags); break; case DECLTYPE_TYPE: - pp_cxx_ws_string (cxx_pp, "decltype"); - pp_cxx_whitespace (cxx_pp); - pp_cxx_left_paren (cxx_pp); - dump_expr (DECLTYPE_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS); - pp_cxx_right_paren (cxx_pp); + pp_cxx_ws_string (pp, "decltype"); + pp_cxx_whitespace (pp); + pp_cxx_left_paren (pp); + dump_expr (pp, DECLTYPE_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS); + pp_cxx_right_paren (pp); break; case NULLPTR_TYPE: - pp_string (cxx_pp, "std::nullptr_t"); + pp_string (pp, "std::nullptr_t"); break; default: - pp_unsupported_tree (cxx_pp, t); + pp_unsupported_tree (pp, t); /* Fall through to error. */ case ERROR_MARK: - pp_string (cxx_pp, M_("")); + pp_string (pp, M_("")); break; } } @@ -560,16 +563,16 @@ dump_type (tree t, int flags) a TYPENAME_TYPE. */ static void -dump_typename (tree t, int flags) +dump_typename (cxx_pretty_printer *pp, tree t, int flags) { tree ctx = TYPE_CONTEXT (t); if (TREE_CODE (ctx) == TYPENAME_TYPE) - dump_typename (ctx, flags); + dump_typename (pp, ctx, flags); else - dump_type (ctx, flags & ~TFF_CLASS_KEY_OR_ENUM); - pp_cxx_colon_colon (cxx_pp); - dump_decl (TYPENAME_TYPE_FULLNAME (t), flags); + dump_type (pp, ctx, flags & ~TFF_CLASS_KEY_OR_ENUM); + pp_cxx_colon_colon (pp); + dump_decl (pp, TYPENAME_TYPE_FULLNAME (t), flags); } /* Return the name of the supplied aggregate, or enumeral type. */ @@ -596,17 +599,17 @@ class_key_or_enum_as_string (tree t) in the form `class foo'. */ static void -dump_aggr_type (tree t, int flags) +dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags) { tree name; const char *variety = class_key_or_enum_as_string (t); int typdef = 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) - pp_cxx_ws_string (cxx_pp, variety); + pp_cxx_ws_string (pp, variety); name = TYPE_NAME (t); @@ -634,7 +637,7 @@ dump_aggr_type (tree t, int flags) || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t))); 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; if (tmplate) { @@ -652,23 +655,24 @@ dump_aggr_type (tree t, int flags) if (name == 0 || ANON_AGGRNAME_P (name)) { if (flags & TFF_CLASS_KEY_OR_ENUM) - pp_string (cxx_pp, M_("")); + pp_string (pp, M_("")); else - pp_printf (cxx_pp, M_(""), variety); + pp_printf (pp, M_(""), variety); } else if (LAMBDA_TYPE_P (t)) { /* A lambda's "type" is essentially its signature. */ - pp_string (cxx_pp, M_("padding = pp_before; - pp_cxx_cv_qualifier_seq (cxx_pp, t); + pp->padding = pp_before; + pp_cxx_cv_qualifier_seq (pp, t); } break; case 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 */ { - pp_maybe_space (cxx_pp); + pp_maybe_space (pp); if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) - pp_cxx_left_paren (cxx_pp); - dump_type (TYPE_OFFSET_BASETYPE (t), flags); - pp_cxx_colon_colon (cxx_pp); + pp_cxx_left_paren (pp); + dump_type (pp, TYPE_OFFSET_BASETYPE (t), flags); + pp_cxx_colon_colon (pp); } - pp_cxx_star (cxx_pp); - pp_cxx_cv_qualifier_seq (cxx_pp, t); - cxx_pp->padding = pp_before; + pp_cxx_star (pp); + pp_cxx_cv_qualifier_seq (pp, t); + pp->padding = pp_before; break; /* This can be reached without a pointer when dealing with templates, e.g. std::is_function. */ case FUNCTION_TYPE: - dump_type_prefix (TREE_TYPE (t), flags); + dump_type_prefix (pp, TREE_TYPE (t), flags); break; case METHOD_TYPE: - dump_type_prefix (TREE_TYPE (t), flags); - pp_maybe_space (cxx_pp); - pp_cxx_left_paren (cxx_pp); - dump_aggr_type (TYPE_METHOD_BASETYPE (t), flags); - pp_cxx_colon_colon (cxx_pp); + dump_type_prefix (pp, TREE_TYPE (t), flags); + pp_maybe_space (pp); + pp_cxx_left_paren (pp); + dump_aggr_type (pp, TYPE_METHOD_BASETYPE (t), flags); + pp_cxx_colon_colon (pp); break; case ARRAY_TYPE: - dump_type_prefix (TREE_TYPE (t), flags); + dump_type_prefix (pp, TREE_TYPE (t), flags); break; case ENUMERAL_TYPE: @@ -780,15 +784,15 @@ dump_type_prefix (tree t, int flags) case TYPE_PACK_EXPANSION: case FIXED_POINT_TYPE: case NULLPTR_TYPE: - dump_type (t, flags); - cxx_pp->padding = pp_before; + dump_type (pp, t, flags); + pp->padding = pp_before; break; default: - pp_unsupported_tree (cxx_pp, t); + pp_unsupported_tree (pp, t); /* fall through. */ case ERROR_MARK: - pp_string (cxx_pp, M_("")); + pp_string (pp, M_("")); break; } } @@ -797,7 +801,7 @@ dump_type_prefix (tree t, int flags) which appears after the identifier (or function parms). */ 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)) t = TYPE_PTRMEMFUNC_FN_TYPE (t); @@ -809,8 +813,8 @@ dump_type_suffix (tree t, int flags) case OFFSET_TYPE: if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) - pp_cxx_right_paren (cxx_pp); - dump_type_suffix (TREE_TYPE (t), flags); + pp_cxx_right_paren (pp); + dump_type_suffix (pp, TREE_TYPE (t), flags); break; case FUNCTION_TYPE: @@ -819,34 +823,34 @@ dump_type_suffix (tree t, int flags) tree arg; if (TREE_CODE (t) == METHOD_TYPE) /* Can only be reached through a pointer. */ - pp_cxx_right_paren (cxx_pp); + pp_cxx_right_paren (pp); arg = TYPE_ARG_TYPES (t); if (TREE_CODE (t) == METHOD_TYPE) arg = TREE_CHAIN (arg); /* Function pointers don't have default args. Not in standard C++, 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_cxx_cv_qualifiers (cxx_pp, type_memfn_quals (t)); - dump_ref_qualifier (t, flags); - dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), flags); - dump_type_suffix (TREE_TYPE (t), flags); + pp->padding = pp_before; + pp_cxx_cv_qualifiers (pp, type_memfn_quals (t)); + dump_ref_qualifier (pp, t, flags); + dump_exception_spec (pp, TYPE_RAISES_EXCEPTIONS (t), flags); + dump_type_suffix (pp, TREE_TYPE (t), flags); break; } case ARRAY_TYPE: - pp_maybe_space (cxx_pp); - pp_cxx_left_bracket (cxx_pp); + pp_maybe_space (pp); + pp_cxx_left_bracket (pp); if (TYPE_DOMAIN (t)) { tree dtype = TYPE_DOMAIN (t); tree max = TYPE_MAX_VALUE (dtype); if (integer_all_onesp (max)) - pp_character (cxx_pp, '0'); + pp_character (pp, '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 { STRIP_NOPS (max); @@ -863,11 +867,11 @@ dump_type_suffix (tree t, int flags) max = fold_build2_loc (input_location, PLUS_EXPR, dtype, max, 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); - dump_type_suffix (TREE_TYPE (t), flags); + pp_cxx_right_bracket (pp); + dump_type_suffix (pp, TREE_TYPE (t), flags); break; case ENUMERAL_TYPE: @@ -897,7 +901,7 @@ dump_type_suffix (tree t, int flags) break; default: - pp_unsupported_tree (cxx_pp, t); + pp_unsupported_tree (pp, t); case ERROR_MARK: /* Don't mark it here, we should have already done in dump_type_prefix. */ @@ -906,7 +910,7 @@ dump_type_suffix (tree t, int flags) } static void -dump_global_iord (tree t) +dump_global_iord (cxx_pretty_printer *pp, tree t) { const char *p = NULL; @@ -917,51 +921,51 @@ dump_global_iord (tree t) else gcc_unreachable (); - pp_printf (cxx_pp, p, input_filename); + pp_printf (pp, p, input_filename); } 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 (VAR_P (t) && DECL_DECLARED_CONSTEXPR_P (t)) - pp_cxx_ws_string (cxx_pp, "constexpr"); - dump_type_prefix (type, flags & ~TFF_UNQUALIFIED_NAME); - pp_maybe_space (cxx_pp); + pp_cxx_ws_string (pp, "constexpr"); + dump_type_prefix (pp, type, flags & ~TFF_UNQUALIFIED_NAME); + pp_maybe_space (pp); } if (! (flags & TFF_UNQUALIFIED_NAME) && TREE_CODE (t) != PARM_DECL && (!DECL_INITIAL (t) || 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; if ((flags & TFF_DECL_SPECIFIERS) && DECL_TEMPLATE_PARM_P (t) && TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (t))) - pp_string (cxx_pp, "..."); + pp_string (pp, "..."); if (DECL_NAME (t)) { if (TREE_CODE (t) == FIELD_DECL && DECL_NORMAL_CAPTURE_P (t)) { - pp_less (cxx_pp); - pp_string (cxx_pp, IDENTIFIER_POINTER (DECL_NAME (t)) + 2); - pp_string (cxx_pp, " capture>"); + pp_less (pp); + pp_string (pp, IDENTIFIER_POINTER (DECL_NAME (t)) + 2); + pp_string (pp, " capture>"); } else - dump_decl (DECL_NAME (t), flags); + dump_decl (pp, DECL_NAME (t), flags); } else - pp_string (cxx_pp, M_("")); + pp_string (pp, M_("")); 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. */ static void -dump_decl (tree t, int flags) +dump_decl (cxx_pretty_printer *pp, tree t, int flags) { if (t == NULL_TREE) return; @@ -973,7 +977,7 @@ dump_decl (tree t, int flags) const char *demangled = objc_maybe_printable_name (t, flags); if (demangled) { - pp_string (cxx_pp, demangled); + pp_string (pp, demangled); return; } } @@ -988,32 +992,32 @@ dump_decl (tree t, int flags) && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM) { /* 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. */ 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; } if (TYPE_DECL_ALIAS_P (t) && (flags & TFF_DECL_SPECIFIERS || flags & TFF_CLASS_KEY_OR_ENUM)) { - pp_cxx_ws_string (cxx_pp, "using"); - dump_decl (DECL_NAME (t), flags); - pp_cxx_whitespace (cxx_pp); - pp_cxx_ws_string (cxx_pp, "="); - pp_cxx_whitespace (cxx_pp); - dump_type (DECL_ORIGINAL_TYPE (t), flags); + pp_cxx_ws_string (pp, "using"); + dump_decl (pp, DECL_NAME (t), flags); + pp_cxx_whitespace (pp); + pp_cxx_ws_string (pp, "="); + pp_cxx_whitespace (pp); + dump_type (pp, DECL_ORIGINAL_TYPE (t), flags); break; } if ((flags & TFF_DECL_SPECIFIERS) && !DECL_SELF_REFERENCE_P (t)) - pp_cxx_ws_string (cxx_pp, "typedef"); - dump_simple_decl (t, DECL_ORIGINAL_TYPE (t) + pp_cxx_ws_string (pp, "typedef"); + dump_simple_decl (pp, t, DECL_ORIGINAL_TYPE (t) ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), flags); break; @@ -1021,78 +1025,78 @@ dump_decl (tree t, int flags) case VAR_DECL: 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))); - dump_type (DECL_CONTEXT (t), flags); + dump_type (pp, DECL_CONTEXT (t), flags); break; } /* Else fall through. */ case FIELD_DECL: case PARM_DECL: - dump_simple_decl (t, TREE_TYPE (t), flags); + dump_simple_decl (pp, t, TREE_TYPE (t), flags); break; case RESULT_DECL: - pp_string (cxx_pp, M_(" ")); - dump_simple_decl (t, TREE_TYPE (t), flags); + pp_string (pp, M_(" ")); + dump_simple_decl (pp, t, TREE_TYPE (t), flags); break; case NAMESPACE_DECL: if (flags & TFF_DECL_SPECIFIERS) - pp_cxx_declaration (cxx_pp, t); + pp_cxx_declaration (pp, t); else { if (! (flags & TFF_UNQUALIFIED_NAME)) - dump_scope (CP_DECL_CONTEXT (t), flags); + dump_scope (pp, CP_DECL_CONTEXT (t), flags); flags &= ~TFF_UNQUALIFIED_NAME; if (DECL_NAME (t) == NULL_TREE) { - if (!(cxx_pp->flags & pp_c_flag_gnu_v3)) - pp_cxx_ws_string (cxx_pp, M_("{anonymous}")); + if (!(pp->flags & pp_c_flag_gnu_v3)) + pp_cxx_ws_string (pp, M_("{anonymous}")); else - pp_cxx_ws_string (cxx_pp, M_("(anonymous namespace)")); + pp_cxx_ws_string (pp, M_("(anonymous namespace)")); } else - pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); + pp_cxx_tree_identifier (pp, DECL_NAME (t)); } break; case SCOPE_REF: - dump_type (TREE_OPERAND (t, 0), flags); - pp_colon_colon (cxx_pp); - dump_decl (TREE_OPERAND (t, 1), TFF_UNQUALIFIED_NAME); + dump_type (pp, TREE_OPERAND (t, 0), flags); + pp_colon_colon (pp); + dump_decl (pp, TREE_OPERAND (t, 1), TFF_UNQUALIFIED_NAME); break; case ARRAY_REF: - dump_decl (TREE_OPERAND (t, 0), flags); - pp_cxx_left_bracket (cxx_pp); - dump_decl (TREE_OPERAND (t, 1), flags); - pp_cxx_right_bracket (cxx_pp); + dump_decl (pp, TREE_OPERAND (t, 0), flags); + pp_cxx_left_bracket (pp); + dump_decl (pp, TREE_OPERAND (t, 1), flags); + pp_cxx_right_bracket (pp); break; case ARRAY_NOTATION_REF: - dump_decl (ARRAY_NOTATION_ARRAY (t), flags | TFF_EXPR_IN_PARENS); - pp_cxx_left_bracket (cxx_pp); - dump_decl (ARRAY_NOTATION_START (t), flags | TFF_EXPR_IN_PARENS); - pp_colon (cxx_pp); - dump_decl (ARRAY_NOTATION_LENGTH (t), flags | TFF_EXPR_IN_PARENS); - pp_colon (cxx_pp); - dump_decl (ARRAY_NOTATION_STRIDE (t), flags | TFF_EXPR_IN_PARENS); - pp_cxx_right_bracket (cxx_pp); + dump_decl (pp, ARRAY_NOTATION_ARRAY (t), flags | TFF_EXPR_IN_PARENS); + pp_cxx_left_bracket (pp); + dump_decl (pp, ARRAY_NOTATION_START (t), flags | TFF_EXPR_IN_PARENS); + pp_colon (pp); + dump_decl (pp, ARRAY_NOTATION_LENGTH (t), flags | TFF_EXPR_IN_PARENS); + pp_colon (pp); + dump_decl (pp, ARRAY_NOTATION_STRIDE (t), flags | TFF_EXPR_IN_PARENS); + pp_cxx_right_bracket (pp); break; /* So that we can do dump_decl on an aggr type. */ case RECORD_TYPE: case UNION_TYPE: case ENUMERAL_TYPE: - dump_type (t, flags); + dump_type (pp, t, flags); break; case BIT_NOT_EXPR: /* This is a pseudo destructor call which has not been folded into a PSEUDO_DTOR_EXPR yet. */ - pp_cxx_complement (cxx_pp); - dump_type (TREE_OPERAND (t, 0), flags); + pp_cxx_complement (pp); + dump_type (pp, TREE_OPERAND (t, 0), flags); break; case TYPE_EXPR: @@ -1104,13 +1108,13 @@ dump_decl (tree t, int flags) case IDENTIFIER_NODE: if (IDENTIFIER_TYPENAME_P (t)) { - pp_cxx_ws_string (cxx_pp, "operator"); + pp_cxx_ws_string (pp, "operator"); /* Not exactly IDENTIFIER_TYPE_VALUE. */ - dump_type (TREE_TYPE (t), flags); + dump_type (pp, TREE_TYPE (t), flags); break; } else - pp_cxx_tree_identifier (cxx_pp, t); + pp_cxx_tree_identifier (pp, t); break; case OVERLOAD: @@ -1119,15 +1123,15 @@ dump_decl (tree t, int flags) t = OVL_CURRENT (t); if (DECL_CLASS_SCOPE_P (t)) { - dump_type (DECL_CONTEXT (t), flags); - pp_cxx_colon_colon (cxx_pp); + dump_type (pp, DECL_CONTEXT (t), flags); + pp_cxx_colon_colon (pp); } else if (!DECL_FILE_SCOPE_P (t)) { - dump_decl (DECL_CONTEXT (t), flags); - pp_cxx_colon_colon (cxx_pp); + dump_decl (pp, DECL_CONTEXT (t), flags); + pp_cxx_colon_colon (pp); } - dump_decl (DECL_NAME (t), flags); + dump_decl (pp, DECL_NAME (t), flags); break; } @@ -1138,15 +1142,15 @@ dump_decl (tree t, int flags) case FUNCTION_DECL: if (! DECL_LANG_SPECIFIC (t)) - pp_string (cxx_pp, M_("")); + pp_string (pp, M_("")); else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t)) - dump_global_iord (t); + dump_global_iord (pp, t); else - dump_function_decl (t, flags); + dump_function_decl (pp, t, flags); break; case TEMPLATE_DECL: - dump_template_decl (t, flags); + dump_template_decl (pp, t, flags); break; case TEMPLATE_ID_EXPR: @@ -1156,71 +1160,71 @@ dump_decl (tree t, int flags) if (is_overloaded_fn (name)) name = DECL_NAME (get_first_fn (name)); - dump_decl (name, flags); - pp_cxx_begin_template_argument_list (cxx_pp); + dump_decl (pp, name, flags); + pp_cxx_begin_template_argument_list (pp); if (args == error_mark_node) - pp_string (cxx_pp, M_("