C++ PATCH: ice on duplicate defns

Nathan Sidwell nathan@acm.org
Fri Jun 4 02:00:00 GMT 1999


Hi,
even though we attempt to accept duplicate struct definitions (after erroring),
we don't quite get it right in duplicate_tag_error and ICE later on in
finish_struct_1, and (I forget where) in pt.c.

This patch amends duplicate_tag_error to not clear out the template information
(for a template class), and to clear out the unprocessed inline function nodes.
The latter is because before finish_struct_1, CLASSTYPE_INLINE_FRIENDS holds
the function bodies and afterwards TYPE_NONCOPIED_PARTS is set up. Both these
slots are one and the same ...

I attach a testcase.

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-06-03  Nathan Sidwell  <nathan@acm.org>

	* class.c (duplicate_tag_error): Preserve template information.
	Clear inline bodies.

Index: egcs/gcc/cp/class.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cp/class.c,v
retrieving revision 1.161
diff -c -3 -p -r1.161 class.c
*** class.c	1999/06/03 07:16:10	1.161
--- class.c	1999/06/04 08:23:48
*************** duplicate_tag_error (t)
*** 2132,2137 ****
--- 2132,2139 ----
        tree binfo = TYPE_BINFO (t);
        int interface_only = CLASSTYPE_INTERFACE_ONLY (t);
        int interface_unknown = CLASSTYPE_INTERFACE_UNKNOWN (t);
+       tree template_info = CLASSTYPE_TEMPLATE_INFO (t);
+       int use_template = CLASSTYPE_USE_TEMPLATE (t);
  
        bzero ((char *) TYPE_LANG_SPECIFIC (t), sizeof (struct lang_type));
        BINFO_BASETYPES(binfo) = NULL_TREE;
*************** duplicate_tag_error (t)
*** 2140,2145 ****
--- 2142,2149 ----
        CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
        SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
        TYPE_REDEFINED (t) = 1;
+       CLASSTYPE_TEMPLATE_INFO (t) = template_info;
+       CLASSTYPE_USE_TEMPLATE (t) = use_template;
      }
    TYPE_SIZE (t) = NULL_TREE;
    TYPE_MODE (t) = VOIDmode;
*************** duplicate_tag_error (t)
*** 2147,2152 ****
--- 2151,2158 ----
    TYPE_METHODS (t) = NULL_TREE;
    TYPE_VFIELD (t) = NULL_TREE;
    TYPE_CONTEXT (t) = NULL_TREE;
+   
+   CLASSTYPE_INLINE_FRIENDS (t) = NULL_TREE;
  }
  
  /* finish up all new vtables.  */


More information about the Gcc-patches mailing list