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]

Re: mutable members in global const objects


> In summary, I'm not familiar enough with the internals of g++ to have a
> go at it. I would, however, be willing to have a go at option 3 and
> adding a language specific flag to tree_type, if someone could offer
> some guidance on how to proceed.

Looking at the various implementations of SELECT_SECTION, it seems
that they

a) contain a large amount of front-end code
b) are in various degrees of completion. I'd assume that versions
   that check for more conditions (e.g. volatility, presence of
   constructors) are most likely more recent than versions that do
   not

So, I'd consider this whole thing a bug, and would propose a slightly
modified version of your option 1:

Move all the front-end code (i.e. the stuff dealing with initializers)
into a tree.c function, e.g. var_readonly_p. Then replace in all
SELECT_DECL implementations all that stuff with that function
(keeping, of course, platform specifics in the macro,
e.g. PIC). Finally, make the test platform specific; for cp, you'd
get

  int lang_var_readonly_p(decl)
  {
    return var_readonly_p(decl) && has_no_mutables(decl);
  }

You'd then actually call the lang_ version in the macros.

This is a major change, and would require quite some review. So if I'm
missing the obvious, please let us know.

Regards,
Martin


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