This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: (C++) patch to protected member access
- To: Mark Mitchell <mark at codesourcery dot com>
- Subject: Re: (C++) patch to protected member access
- From: Jason Merrill <jason at cygnus dot com>
- Date: 28 Feb 2000 14:43:50 -0800
- Cc: a8601248 at unet dot univie dot ac dot at, gcc-patches at gcc dot gnu dot org
- References: <38BA248B.55016395@unet.univie.ac.at> <u9d7phjmia.fsf@yorick.cygnus.com> <20000228105613E.mitchell@codesourcery.com>
>>>>> Mark Mitchell <mark@codesourcery.com> writes:
> I think the standard can be construed as correct if you don't smash
> using declarations to the things they refer to. (As we've discussed
> privately, G++ does this internally, but that doesn't mean the
> standard does.)
> The standard says that using declarations are a synonym -- it doesn't
> say that there some kind of semantic macro that sucks in all the
> referred-to functions. So, I think the program is legal because name
> look for the call to `f' finds `B::f', which is a public using
> declaration.
Hmm, that makes sense.
> So, I think that instead of your patch we should bite the bullet on
> the handling of using declarations. It should be relatively easy to,
> instead of actually inserting the functions in the class, just put a
> USING_DECL which contains a list of the functions that would have been
> inserted.
Note that my patch also fixes
struct A {
protected:
int i;
};
struct B: public A { };
struct C: public A {
void f () {
B::i = 0;
}
};
Here, i is accessible when named in B because it's accessible when named in
A. Before my patch, g++ was treating B specially in
protected_accessible_p, which is not appropriate.
I suppose we could change it back to check for private or protected access,
but I'd rather leave it for now.
Jason