public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* intermodule and comptypes - need some help
@ 2003-08-07 13:42 Zack Weinberg
  2003-08-07 19:43 ` Geoff Keating
  0 siblings, 1 reply; 6+ messages in thread
From: Zack Weinberg @ 2003-08-07 13:42 UTC (permalink / raw)
  To: gcc; +Cc: Geoff Keating


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-08-08  2:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-07 13:42 intermodule and comptypes - need some help Zack Weinberg
2003-08-07 19:43 ` Geoff Keating
2003-08-07 21:30   ` Zack Weinberg
2003-08-08  1:46     ` Geoff Keating
2003-08-08  2:52       ` Zack Weinberg
2003-08-08  3:41         ` Geoff Keating

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).