This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[LTO][PATCH] Fix for ICE in cp/mangle.c:839


Fix for ICE in write_unscoped_name, at cp/mangle.c:839.  The patch removes
any template context information that may be held to accompany a given decl.
The decl's context itself is already removed by existing code -- this patch
applies symmetrical treatment to the template information.

gcc/ChangeLog:
2008-09-22  Simon Baldwin  <simonb@google.com>

	* tree.c (reset_lang_specific): Rename to reset_decl_lang_specific,
	add call to reset_lang_specifics langhook.

gcc/cp/ChangeLog:
2008-09-22  Simon Baldwin  <simonb@google.com>

	* tree.h (mangle_decl_is_template_id): New mangler function.
	* mangle.c (mangle_decl_is_template_id): New function, exposes
	decl_is_template_id for langhooks.
	* tree.c (cp_reset_lang_specifics): Reset context information for
	types generated from templates.


Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 140411)
+++ gcc/tree.c	(working copy)
@@ -4000,9 +4000,11 @@ set_asm_name (void **slot, void *unused 
 /* Helper function of free_lang_specifics. */
 
 static int
-reset_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED)
+reset_decl_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED)
 {
   tree decl = *(tree*)slot;
+  lang_hooks.reset_lang_specifics (decl);
+
   if (TREE_CODE (decl) == PARM_DECL
       || TREE_CODE (decl) == FIELD_DECL)
     {
@@ -4065,7 +4067,7 @@ free_lang_specifics (void)
      will fail after we strip DECL_CONTEXT from declaration nodes.  */
   htab_traverse (decl_for_uid_map, set_asm_name, NULL);
 
-  htab_traverse (decl_for_uid_map, reset_lang_specific, NULL);
+  htab_traverse (decl_for_uid_map, reset_decl_lang_specific, NULL);
   htab_traverse (uid2type_map, reset_type_lang_specific, NULL);
 
   /* FIXME lto.  This is a hack.  ptrdiff_type_node is only created
Index: gcc/cp/tree.c
===================================================================
--- gcc/cp/tree.c	(revision 140550)
+++ gcc/cp/tree.c	(working copy)
@@ -2812,6 +2812,14 @@ cp_reset_lang_specifics (tree t)
 	  argtypes = TREE_CHAIN (argtypes);
 	}
     }
+  else if (TREE_CODE (t) == TYPE_DECL)
+    {
+      tree template_info;
+
+      /* Remove context information held in templated decls.  */
+      if (mangle_decl_is_template_id (t, &template_info))
+        DECL_CONTEXT (TREE_PURPOSE (template_info)) = NULL_TREE;
+    }
 }
 
 
Index: gcc/cp/mangle.c
===================================================================
--- gcc/cp/mangle.c	(revision 140550)
+++ gcc/cp/mangle.c	(working copy)
@@ -2926,6 +2926,15 @@ mangle_ref_init_variable (const tree var
   write_name (variable, /*ignore_local_scope=*/0);
   return finish_mangling_get_identifier (/*warn=*/false);
 }
+
+/* Return true if decl is templated, along with the associated template info
+   node.  TEMPLATE_INFO may be null.  */
+
+int
+mangle_decl_is_template_id (const tree decl, tree* const template_info)
+{
+  return decl_is_template_id (decl, template_info);
+}
 
 
 /* Foreign language type mangling section.  */
Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h	(revision 140550)
+++ gcc/cp/cp-tree.h	(working copy)
@@ -5015,6 +5015,7 @@ extern tree mangle_thunk			(tree, int, t
 extern tree mangle_conv_op_name_for_type	(tree);
 extern tree mangle_guard_variable		(tree);
 extern tree mangle_ref_init_variable		(tree);
+extern int mangle_decl_is_template_id		(const tree, tree* const);
 extern tree mangle_compound_literal		(void);
 
 /* in dump.c */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]