re PR c++/11811 (Weird message with default template arguments)
authorGabriel Dos Reis <gdr@integrable-solutions.net>
Fri, 29 Aug 2003 07:00:32 +0000 (07:00 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Fri, 29 Aug 2003 07:00:32 +0000 (07:00 +0000)
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

gcc/cp/ChangeLog
gcc/cp/cxx-pretty-print.c
gcc/cp/cxx-pretty-print.h
gcc/cp/error.c

index 402b17720906eb6141a6cb2fbdd47abe51248108..60c81ab4fad703e5fc5085bedaf5a468335e3e9b 100644 (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.
index 543cc322151cc8bf7a33a1dc467cc7bd21383088..2efe0bc26bf3f563f2eff7c50cd8e80cd2340c07 100644 (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   */
index 1fa0b99b6ff76c90da189670b9a3dd8afba7b8d2..d75c2827f950d37219b922182b6d954df8352938 100644 (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);
 
 
index 9aeb555c615033fe0df690bc3277a8725b3270af..aa7534ed086e4ccb4b0e194c0cc31fb610c272b5 100644 (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