+2003-08-29 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ PR c++/11811
+ * cxx-pretty-print.c (pp_cxx_canonical_template_parameter): New
+ function.
+ * cxx-pretty-print.h: Declare.
+ * error.c (dump_template_parameter): Use it.
+ (dump_type): Likewise.
+
2003-08-28 Mark Mitchell <mark@codesourcery.com>
* init.c (decl_constant_value): Deal with COND_EXPR specially.
}
}
+/* Pretty-print a template parameter in the canonical form
+ "template-parameter-<level>-<position in parameter list>". */
+
+void
+pp_cxx_canonical_template_parameter (cxx_pretty_printer *pp, tree parm)
+{
+ const enum tree_code code = TREE_CODE (parm);
+
+ /* Brings type template parameters to the canonical forms */
+ if (code == TEMPLATE_TYPE_PARM || code == TEMPLATE_TEMPLATE_PARM
+ || code == BOUND_TEMPLATE_TEMPLATE_PARM)
+ parm = TEMPLATE_TYPE_PARM_INDEX (parm);
+
+ pp_cxx_begin_template_argument_list (pp);
+ pp_cxx_identifier (pp, "template-parameter-");
+ pp_wide_integer (pp, TEMPLATE_PARM_LEVEL (parm));
+ pp_minus (pp);
+ pp_wide_integer (pp, TEMPLATE_PARM_IDX (parm) + 1);
+ pp_cxx_end_template_argument_list (pp);
+}
+
/*
template-declaration:
export(opt) template < template-parameter-list > declaration */
void pp_cxx_declaration (cxx_pretty_printer *, tree);
void pp_cxx_function_definition (cxx_pretty_printer *, tree);
+void pp_cxx_canonical_template_parameter (cxx_pretty_printer *, tree);
void pp_cxx_statement (cxx_pretty_printer *, tree);
else if (DECL_NAME (p))
pp_tree_identifier (cxx_pp, DECL_NAME (p));
else
- pp_identifier (cxx_pp, "<template default argument error>");
+ pp_cxx_canonical_template_parameter (cxx_pp, TREE_TYPE (p));
}
else
dump_decl (p, flags | TFF_DECL_SPECIFIERS);
if (TYPE_IDENTIFIER (t))
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
- pp_identifier (cxx_pp, "<anonymous template template parameter>");
+ pp_cxx_canonical_template_parameter (cxx_pp, t);
break;
case BOUND_TEMPLATE_TEMPLATE_PARM:
if (TYPE_IDENTIFIER (t))
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
- pp_identifier (cxx_pp, "<anonymous template type parameter>");
+ pp_cxx_canonical_template_parameter
+ (cxx_pp, TEMPLATE_TYPE_PARM_INDEX (t));
break;
/* This is not always necessary for pointers and such, but doing this