re PR c++/11811 (Weird message with default template arguments)

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.

From-SVN: r70905
This commit is contained in:
Gabriel Dos Reis 2003-08-29 07:00:32 +00:00 committed by Gabriel Dos Reis
parent 5c14415811
commit b251717302
4 changed files with 35 additions and 3 deletions

View File

@ -1,3 +1,12 @@
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.

View File

@ -1538,6 +1538,27 @@ pp_cxx_template_parameter (cxx_pretty_printer *pp, tree t)
}
}
/* 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 */

View File

@ -47,6 +47,7 @@ void pp_cxx_pretty_printer_init (cxx_pretty_printer *);
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);

View File

@ -227,7 +227,7 @@ dump_template_parameter (tree parm, int flags)
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);
@ -384,7 +384,7 @@ dump_type (tree t, int flags)
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:
@ -402,7 +402,8 @@ dump_type (tree t, int flags)
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