This is the mail archive of the 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]

Re: Candidate fix for PR 15007

> X-Original-To:
> Cc:
> From: Zack Weinberg <>
> Date: Mon, 03 May 2004 12:08:33 -0700
> X-OriginalArrivalTime: 03 May 2004 19:09:43.0531 (UTC) FILETIME=[3124BBB0:01C43142]
> Geoff Keating <> writes:
> > Zack Weinberg <> writes:
> >
> >> It seems to me that the most straightforward way to fix PR 15007 is to
> >> avoid generating a TRANSLATION_UNIT_DECL at all until we're done
> >> parsing the entire translation unit.  This mirrors what is done with
> >> BLOCK nodes - we create them only when the scope is popped.
> >> Fortunately, DECL_FILE_SCOPE_P can already handle this, so the change
> >> is limited to c-decl.c.
> >
> > This isn't exactly what your patch does.  If I'm reading it right, it
> > defers creating the TRANSLATION_UNIT_DECL until the first global
> > declaration is seen.  The approach you described would have been
> > trouble, but the one actually implemented looks like it would work.
> Hein?  It's created in pop_scope when the file scope is popped.  Which
> happens exactly when the translation unit is complete.  We then go
> back and fix up DECL_CONTEXT for everything in that scope.  This works
> because everything that checks DECL_CONTEXT accepts 0 as meaning file
> scope.  Is there something I'm missing?

Hmmm.  I may have misread your patch.

If so, you'll have problems with IMA.  When DECL_ASSEMBLER_NAME is
being set, which can happen much earlier than at the end of the
translation unit (in some cases), it tests DECL_CONTEXT.  It accepts 0
as meaning "there can be only one of these" and non-zero values as
"there might be more than one".  See lhd_set_decl_assembler_name in

In theory, there is no reason why DECL_ASSEMBLER_NAME should be set
before the end of compilation.  You could easily ensure this by
changing c_static_assembler_name to do:

if (!TREE_PUBLIC (decl) && !DECL_CONTEXT (decl))
  abort ();

and then fixing all the cases where this triggers; but I suspect some
of them are hard to fix.

- Geoffrey Keating <>

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