This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
intermodule and comptypes - need some help
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Geoff Keating <geoffk at geoffk dot org>
- Date: Wed, 06 Aug 2003 23:59:20 -0700
- Subject: intermodule and comptypes - need some help
A patch I'm working on has, as a side effect, that (in intermodule
mode) duplicate_decls may encounter two declarations from different
translation units at any time, not just during
merge_translation_unit_decls. It therefore cannot simply be told when
to invoke comptypes with the special COMPARE_DIFFERENT_TU flag. I
tried to write a function which would detect when two types came from
different translation units, but it doesn't work: --enable-intermodule
bootstrap blows up with tons of spurious duplicate declarations.
This is the code I wrote:-
/* Determine whether two types derive from the same translation unit.
If the CONTEXT chain ends in a null, that type's context is still
being parsed, so if two types have context chains ending in null,
they're in the same translation unit. */
static int
same_translation_unit_p (tree t1, tree t2)
{
while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL)
switch (TREE_CODE_CLASS (TREE_CODE (t1)))
{
case 'd': t1 = DECL_CONTEXT (t1); break;
case 't': t1 = TYPE_CONTEXT (t1); break;
case 'b': t1 = BLOCK_SUPERCONTEXT (t1); break;
default: abort ();
}
while (t2 && TREE_CODE (t2) != TRANSLATION_UNIT_DECL)
switch (TREE_CODE_CLASS (TREE_CODE (t2)))
{
case 'd': t2 = DECL_CONTEXT (t1); break;
case 't': t2 = TYPE_CONTEXT (t2); break;
case 'b': t2 = BLOCK_SUPERCONTEXT (t2); break;
default: abort ();
}
return t1 == t2;
}
This replaces the flags check guarding the call to
tagged_types_tu_compatible_p. What am I doing wrong?
zw