Problem with your template printing change
gdr@codesourcery.com
gdr@codesourcery.com
Thu Sep 30 19:57:00 GMT 1999
Mark Mitchell <mark@codesourcery.com> writes:
| Compiling the following test-case without -quiet (i.e., running
| `cc1plus test.C' directly) causes `sorry' error messages to appear. I
| think your code is probably not handling templates with multiple
| levels of template parameters correctly.
[...]
Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> writes:
| This is for some code I may not release and I did not manage to generate
| a small testcase in decent time, but perhaps the messages suffice?
|
| (If not, I'll work even harder to generate a test case.)
|
| Current CVS repository.
[...]
| /sw/test/gcc/SunOS/lib/gcc-lib/sparc-sun-solaris2.6/2.96/../../../../include/g++-3/stl_vector.h:456:
| sorry, not implemented: `tree_vec' not supported by dump_expr
Mark, Gerald --
The patch above should repair the damage my previous nonsensical patch
caused.
Is it OK?
-- Gaby
CodeSourcery, LLC
1999-09-29 Gabriel Dos Reis <gdr@codesourcery.com>
* error.c (dump_template_parameter_binding): New function.
(dump_template_bindings): Rename to ...
(dump_template_parameter_list_bindings): ... here. Handle
multi-level template paramaters.
Index: error.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cp/error.c,v
retrieving revision 1.92
diff -p -r1.92 error.c
*** error.c 1999/09/29 01:10:44 1.92
--- error.c 1999/09/29 15:19:14
*************** static tree ident_fndecl PROTO((tree));
*** 92,98 ****
static void dump_template_argument PROTO((tree, enum tree_string_flags));
static void dump_template_argument_list PROTO((tree, enum tree_string_flags));
static void dump_template_parameter PROTO((tree, enum tree_string_flags));
! static void dump_template_bindings PROTO((tree, tree, enum tree_string_flags));
static void dump_scope PROTO((tree, enum tree_string_flags));
static void dump_template_parms PROTO((tree, int, enum tree_string_flags));
--- 92,99 ----
static void dump_template_argument PROTO((tree, enum tree_string_flags));
static void dump_template_argument_list PROTO((tree, enum tree_string_flags));
static void dump_template_parameter PROTO((tree, enum tree_string_flags));
! static void dump_template_paramter_binding PROTO((tree, tree, enum tree_string_flags));
! static void dump_template_parameter_list_bindings PROTO((tree, tree, enum tree_string_flags));
static void dump_scope PROTO((tree, enum tree_string_flags));
static void dump_template_parms PROTO((tree, int, enum tree_string_flags));
*************** dump_template_parameter (parm, flags)
*** 288,327 ****
}
}
- /* Dump, under control of FLAGS, a template-parameter-list binding.
- PARMS is a TREE_LIST of TREE_VEC of TREE_LIST and ARGS is a
- TREE_VEC. */
static void
! dump_template_bindings (parms, args, flags)
tree parms, args;
enum tree_string_flags flags;
{
! int arg_idx = 0;
int need_comma = 0;
while (parms)
{
! tree p = TREE_VALUE (parms);
! int i;
! for (i = 0; i < TREE_VEC_LENGTH (p); ++i)
! {
! tree arg = TREE_VEC_ELT (args, arg_idx);
! if (need_comma)
! OB_PUTS (", ");
! dump_template_parameter (TREE_VEC_ELT (p, i), TS_PLAIN);
! OB_PUTS (" = ");
! if (arg)
! dump_template_argument (arg, TS_PLAIN);
! else
! OB_PUTS ("{missing}");
!
! ++arg_idx;
! need_comma = 1;
}
parms = TREE_CHAIN (parms);
}
}
--- 289,350 ----
}
}
+ /* Under control of FLAGS, dump a a template paramter PARM bound to
+ a template argument ARG. */
+
+ static void
+ dump_template_parameter_binding (parm, arg, flags)
+ tree parm, arg;
+ enum tree_string_flags flags;
+ {
+ dump_template_parameter (parm, TS_PLAIN);
+ OB_PUTS (" = ");
+ if (arg)
+ dump_template_argument (arg, flags & TS_AGGR_TAGS);
+ else
+ OB_PUTS ("{missing}");
+ }
+
+
+ /* Under control of FLAGS, dump a template-parameter-list binding.
+ PARMS is a TREE_LIST of TREE_VEC of TREE_LIST and ARGS is a TREE_VEC,
+ or a TREE_VEC of TREE_VEC if multiple level template. */
+
static void
! dump_template_parameter_list_bindings (parms, args, flags)
tree parms, args;
enum tree_string_flags flags;
{
! int args_idx = 0;
int need_comma = 0;
while (parms)
{
! tree one_level_parms = TREE_VALUE (parms);
! tree one_level_args = TREE_VEC_ELT (args, args_idx);
! if (need_comma)
! OB_PUTS (", ");
! if (TREE_CODE (one_level_args) == TREE_VEC)
! {
! int j;
! for (j = 0; j < TREE_VEC_LENGTH (one_level_parms); ++j)
! {
! if (j)
! OB_PUTS (", ");
! dump_template_parameter_binding
! (TREE_VEC_ELT (one_level_parms, j),
! TREE_VEC_ELT (one_level_args, j), flags);
! }
}
+ else
+ dump_template_parameter_binding
+ (TREE_VEC_ELT (one_level_parms, 0), one_level_args, flags);
+ need_comma = 1;
+ ++args_idx;
parms = TREE_CHAIN (parms);
}
}
*************** dump_template_decl (t, flags)
*** 1059,1065 ****
{
if (i)
OB_PUTS (", ");
! dump_template_parameter (TREE_VEC_ELT (args, i), flags);
}
OB_END_TEMPLATE_ID ();
OB_PUTC (' ');
--- 1082,1089 ----
{
if (i)
OB_PUTS (", ");
! dump_template_parameter
! (TREE_VEC_ELT (TREE_VALUE (args), i), flags);
}
OB_END_TEMPLATE_ID ();
OB_PUTC (' ');
*************** dump_function_decl (t, flags)
*** 1184,1190 ****
if (template_parms != NULL_TREE && template_args != NULL_TREE)
{
OB_PUTS (" [with ");
! dump_template_bindings (template_parms, template_args, flags);
OB_PUTC (']');
}
}
--- 1208,1215 ----
if (template_parms != NULL_TREE && template_args != NULL_TREE)
{
OB_PUTS (" [with ");
! dump_template_parameter_list_bindings
! (template_parms, template_args, flags);
OB_PUTC (']');
}
}
More information about the Gcc-bugs
mailing list