This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[mainline] C++: Fix part of PR 11811
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: 29 Aug 2003 09:07:45 +0200
- Subject: [mainline] C++: Fix part of PR 11811
- Organization: Integrable Solutions
This patchlet fixes part of PR C++/11811 where we were being too
confusing in diagnostics. Now, for *unnamed* template parameters,
we're using the "canonical" name "template-parameter<level>-<pos>",
with <level> being the template nesting level and <pos> being the
position in the template parameter list at a given level.
The other part of the PR should be considered separately.
Bootstrapped and regtested on an i686-pc-linux-gnu.
-- Gaby
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/ChangeLog,v
retrieving revision 1.3629
diff -p -r1.3629 ChangeLog
*** ChangeLog 29 Aug 2003 02:50:09 -0000 1.3629
--- ChangeLog 29 Aug 2003 06:13:04 -0000
***************
*** 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.
Index: cxx-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cxx-pretty-print.c,v
retrieving revision 1.4
diff -p -r1.4 cxx-pretty-print.c
*** cxx-pretty-print.c 25 Aug 2003 20:40:21 -0000 1.4
--- cxx-pretty-print.c 29 Aug 2003 06:13:04 -0000
*************** pp_cxx_template_parameter (cxx_pretty_pr
*** 1538,1543 ****
--- 1538,1564 ----
}
}
+ /* 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 */
Index: cxx-pretty-print.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cxx-pretty-print.h,v
retrieving revision 1.3
diff -p -r1.3 cxx-pretty-print.h
*** cxx-pretty-print.h 25 Aug 2003 19:10:50 -0000 1.3
--- cxx-pretty-print.h 29 Aug 2003 06:13:04 -0000
*************** void pp_cxx_pretty_printer_init (cxx_pre
*** 47,52 ****
--- 47,53 ----
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);
Index: error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.232
diff -p -r1.232 error.c
*** error.c 15 Aug 2003 12:15:56 -0000 1.232
--- error.c 29 Aug 2003 06:13:04 -0000
*************** dump_template_parameter (tree parm, int
*** 227,233 ****
else if (DECL_NAME (p))
pp_tree_identifier (cxx_pp, DECL_NAME (p));
else
! pp_identifier (cxx_pp, "<template default argument error>");
}
else
dump_decl (p, flags | TFF_DECL_SPECIFIERS);
--- 227,233 ----
else if (DECL_NAME (p))
pp_tree_identifier (cxx_pp, DECL_NAME (p));
else
! pp_cxx_canonical_template_parameter (cxx_pp, TREE_TYPE (p));
}
else
dump_decl (p, flags | TFF_DECL_SPECIFIERS);
*************** dump_type (tree t, int flags)
*** 384,390 ****
if (TYPE_IDENTIFIER (t))
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
! pp_identifier (cxx_pp, "<anonymous template template parameter>");
break;
case BOUND_TEMPLATE_TEMPLATE_PARM:
--- 384,390 ----
if (TYPE_IDENTIFIER (t))
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
! pp_cxx_canonical_template_parameter (cxx_pp, t);
break;
case BOUND_TEMPLATE_TEMPLATE_PARM:
*************** dump_type (tree t, int flags)
*** 402,408 ****
if (TYPE_IDENTIFIER (t))
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
! pp_identifier (cxx_pp, "<anonymous template type parameter>");
break;
/* This is not always necessary for pointers and such, but doing this
--- 402,409 ----
if (TYPE_IDENTIFIER (t))
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
! 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