diff options
author | Gabriel Dos Reis <gdr@integrable-solutions.net> | 2003-08-29 07:00:32 +0000 |
---|---|---|
committer | Gabriel Dos Reis <gdr@gcc.gnu.org> | 2003-08-29 07:00:32 +0000 |
commit | b251717302c3cd016d84c73deaffac0c73cca824 (patch) | |
tree | 57164a0efc439068c173e46bac935af2b8cd2843 /gcc | |
parent | 5c14415811b48f1b486be91ea41661381f08a3fe (diff) | |
download | gcc-b251717302c3cd016d84c73deaffac0c73cca824.zip gcc-b251717302c3cd016d84c73deaffac0c73cca824.tar.gz gcc-b251717302c3cd016d84c73deaffac0c73cca824.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/cxx-pretty-print.c | 21 | ||||
-rw-r--r-- | gcc/cp/cxx-pretty-print.h | 1 | ||||
-rw-r--r-- | gcc/cp/error.c | 7 |
4 files changed, 35 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 402b177..60c81ab 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 543cc32..2efe0bc 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -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 */ diff --git a/gcc/cp/cxx-pretty-print.h b/gcc/cp/cxx-pretty-print.h index 1fa0b99..d75c282 100644 --- a/gcc/cp/cxx-pretty-print.h +++ b/gcc/cp/cxx-pretty-print.h @@ -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); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 9aeb555..aa7534e 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -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 |