[C++ PATCH] Fix PR4802, 5387

Kriang Lerdsuwanakij lerdsuwa@users.sourceforge.net
Sun May 26 10:59:00 GMT 2002


[Forgot to CC: gcc-patches list.]

Kriang Lerdsuwanakij wrote:
> 
> Gabriel Dos Reis wrote:
> >
> > Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> writes:
> >
> > | Hi
> > |
> > | This patch fixes PR4802 and PR5387 (not a regression).  With the patch
> > | type access is now enforced for typename types while previously they are
> > | all treated as public.
> >
> >   1) I was under the  impression that enforce_access() is used only
> >      for controling access in a derived class to a member defined in
> >      base-classes.  The comment reads:
> >
> >    /* If the current scope isn't allowed to access DECL along
> >       BASETYPE_PATH, give an error.  The most derived class in
> >       BASETYPE_PATH is the one used to qualify DECL.  */
> >
> >      Or do I misread the comment?
> 
> The comment for accessible_p (used by enforce_access) is a bit clearer.
> accessible_p(type,decl): DECL is a declaration from a base class of
> TYPE, which was the class used to name DECL.  So the code
> 'typename CONTEXT::T' translate to enforce_access(CONTEXT,T) function
> call.  The current function/class is taken care of by accessible_p,
> for example, via current_class_type, current_scope().
> 
> >   2) Assuming 1) is resolved psotively, does your patch handle
> >
> >       class X {
> >          struct A { };
> >       public
> >          struct B {
> >             void f();
> >          };
> >       };
> >
> >       void X::B::f()
> >       {
> >          A a;                   // OK - A::B is treated as a friend of X
> >       }
> >
> This case is beyond the scope of my patch.  Mine only deals with
> types declared using 'typename'.  Whether the access is allowed
> is checked when the template parameters are substituted.
> 
> --Kriang



More information about the Gcc-patches mailing list