C++ PATCH: template ICE

Nathan Sidwell nathan@acm.org
Tue Aug 24 03:09:00 GMT 1999


Hi,
the attached patch fixes an ice in g++.ns/template6.C when trying to
instantiate not a template,

Here's the testsuite log delta
< /home/nathan/egcs/devel/egcs/gcc/testsuite/g++.old-deja/g++.ns/template6.C:23: confused by earlier errors, bailing out
---
> /home/nathan/egcs/devel/egcs/gcc/testsuite/g++.old-deja/g++.ns/template6.C:23: A::B is not a template
> /home/nathan/egcs/devel/egcs/gcc/testsuite/g++.old-deja/g++.ns/template6.C:23: parse error before `,'

Ok?

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
        I have seen the death of PhotoShop -- it is called GIMP
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
1999-08-24  Nathan Sidwell  <nathan@acm.org>

	pt.c (instantiate_decl): Check it really is a template.

Index: gcc/cp/pt.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cp/pt.c,v
retrieving revision 1.339
diff -c -3 -p -r1.339 pt.c
*** pt.c	1999/08/22 18:11:39	1.339
--- pt.c	1999/08/24 10:00:50
*************** tree
*** 9473,9480 ****
  instantiate_decl (d)
       tree d;
  {
!   tree tmpl = DECL_TI_TEMPLATE (d);
!   tree args = DECL_TI_ARGS (d);
    tree td;
    tree code_pattern;
    tree spec;
--- 9473,9480 ----
  instantiate_decl (d)
       tree d;
  {
!   tree tmpl;
!   tree args;
    tree td;
    tree code_pattern;
    tree spec;
*************** instantiate_decl (d)
*** 9484,9489 ****
--- 9484,9498 ----
    int line = lineno;
    char *file = input_filename;
  
+   if (TREE_CODE (DECL_TEMPLATE_INFO (d)) != TREE_LIST)
+     {
+       /*  It looked like a template, but isn't really.  */
+       cp_error ("%#D is not a template", d);
+       return error_mark_node;
+     }
+   tmpl = DECL_TI_TEMPLATE (d);
+   args = DECL_TI_ARGS (d);
+   
    /* This function should only be used to instantiate templates for
       functions and static member variables.  */
    my_friendly_assert (TREE_CODE (d) == FUNCTION_DECL


More information about the Gcc-patches mailing list