This is the mail archive of the gcc@gcc.gnu.org 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: TRANSLATION_UNIT_DECL breaks bootstrap


Daniel Berlin <dberlin@dberlin.org> writes:

> >
> >> whereas the "true" globals are clobbered on any call anywhere.
> >> To do this, we need to distinguish between those variables local to a
> >> file, and those that aren't.
> >> HAS_FILE_SCOPE_P would do this.
> >
> > This all seems like it needs to be a langhook.
> 
> No, we aren't doing this on language specific trees, no langhook
> should be necessary or is wanted.

You're making assumptions about what the language allows users to do
or not do, and there's no reason that the language should have any
particular restriction.

> >  How does this work in
> > C++, to handle (for instance) private static variables in classes?
> 
> It works just fine.

So you can tell that the variable can be changed only by methods of
that class?  What do you do with the information?

> >   Do
> > you look at DECL_CONTEXT for that?
> 
> Right now, we aren't field based (IE accesses to a field of a variable
> are globbed to the entire variable), to avoid dealing with this. 

That can't be right.  You mean that if someone writes

struct foo {
  static int x;
  int y;
};

{
  foo a, b;
  b.x = 3;
  a.x = 2;
  printf ("%d\n", b.x);
}

you associate the 'a.x' with 'a' and then assume it doesn't change
'b.x', and print 3 instead of 2?

-- 
- Geoffrey Keating <geoffk@geoffk.org>


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