This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Fix regression in template instantiation code
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: bangerth at ticam dot utexas dot edu
- Date: Mon, 6 Jan 2003 17:35:50 -0800
- Subject: C++ PATCH: Fix regression in template instantiation code
- Reply-to: mark at codesourcery dot com
Wolfgang pointed out that my patch from yesterday to pt.c didn't
really do the trick. It turns out that I misunderstood what was going
wrong in the hash-table code; this patch fixes the problem. I think.
Tested on i686-pc-linux-gnu, applied on the mainline.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2003-01-06 Mark Mitchell <mark@codesourcery.com>
* pt.c (retrieve_local_specialization): Revert 2003-01-05 change.
(hash_local_specialization): New function.
(register_local_specialization): Revert 2003-01-05 change.
(instantiate_decl): Use hash_local_specialization when creating
the local_specializations table.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.643
diff -c -5 -p -r1.643 pt.c
*** cp/pt.c 6 Jan 2003 02:40:31 -0000 1.643
--- cp/pt.c 7 Jan 2003 01:19:20 -0000
*************** retrieve_specialization (tmpl, args)
*** 743,753 ****
static tree
retrieve_local_specialization (tmpl)
tree tmpl;
{
! tree spec = (tree) htab_find (local_specializations, tmpl);
return spec ? TREE_PURPOSE (spec) : NULL_TREE;
}
/* Returns nonzero iff DECL is a specialization of TMPL. */
--- 743,755 ----
static tree
retrieve_local_specialization (tmpl)
tree tmpl;
{
! tree spec =
! (tree) htab_find_with_hash (local_specializations, tmpl,
! htab_hash_pointer (tmpl));
return spec ? TREE_PURPOSE (spec) : NULL_TREE;
}
/* Returns nonzero iff DECL is a specialization of TMPL. */
*************** static int
*** 920,940 ****
eq_local_specializations (const void *p1, const void *p2)
{
return TREE_VALUE ((tree) p1) == (tree) p2;
}
/* Like register_specialization, but for local declarations. We are
registering SPEC, an instantiation of TMPL. */
static void
register_local_specialization (spec, tmpl)
tree spec;
tree tmpl;
{
void **slot;
! slot = htab_find_slot (local_specializations, tmpl, INSERT);
*slot = build_tree_list (spec, tmpl);
}
/* Print the list of candidate FNS in an error message. */
--- 922,951 ----
eq_local_specializations (const void *p1, const void *p2)
{
return TREE_VALUE ((tree) p1) == (tree) p2;
}
+ /* Hash P1, an entry in the local specializations table. */
+
+ static hashval_t
+ hash_local_specialization (const void* p1)
+ {
+ return htab_hash_pointer (TREE_VALUE ((tree) p1));
+ }
+
/* Like register_specialization, but for local declarations. We are
registering SPEC, an instantiation of TMPL. */
static void
register_local_specialization (spec, tmpl)
tree spec;
tree tmpl;
{
void **slot;
! slot = htab_find_slot_with_hash (local_specializations, tmpl,
! htab_hash_pointer (tmpl), INSERT);
*slot = build_tree_list (spec, tmpl);
}
/* Print the list of candidate FNS in an error message. */
*************** instantiate_decl (d, defer_ok)
*** 10306,10316 ****
template from within the body of another. */
saved_local_specializations = local_specializations;
/* Set up the list of local specializations. */
local_specializations = htab_create (37,
! htab_hash_pointer,
eq_local_specializations,
NULL);
/* Set up context. */
start_function (NULL_TREE, d, NULL_TREE, SF_PRE_PARSED);
--- 10317,10327 ----
template from within the body of another. */
saved_local_specializations = local_specializations;
/* Set up the list of local specializations. */
local_specializations = htab_create (37,
! hash_local_specialization,
eq_local_specializations,
NULL);
/* Set up context. */
start_function (NULL_TREE, d, NULL_TREE, SF_PRE_PARSED);