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: Symbol table 21/many: analyze initializers of external vars

> > The problem here seems to be that Ada constructs an variable that is
> > DECL_EXTERNAL, passes const_value_known_p and has DECL_INITIAL, yet its
> > TREE_STATIC is not set. C++ always output those variables with TREE_STATIC
> > set and to be honest, I am unsure what is intended semantics of this flag
> > in this case.
> Ada used to do that (set both DECL_EXTERNAL and TREE_STATIC) but was fixed.
> > Is folding through these variables desirable in Ada?  If not, i would
> > suggest clear DECL_INITIAL (it is useless), if it is, we can either relatex
> > the varpool_finalize_decl check or arrange TREE_STATIC to not be set.
> Yes, this is desirable.

OK, does the following patch fix the problem?  I will try to understand how conistent
is C++ frontend about the flags.  It would be nice to have safer way to declare the
"static var in other unit" than combination of EXTERNAL and STATIC...


Index: cgraphunit.c
--- cgraphunit.c	(revision 187650)
+++ cgraphunit.c	(working copy)
@@ -819,7 +819,7 @@ varpool_finalize_decl (tree decl)
   struct varpool_node *node = varpool_node (decl);
-  gcc_assert (TREE_STATIC (decl));
+  gcc_assert (TREE_STATIC (decl) || DECL_EXTERNAL (decl));
   if (node->finalized)

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