This is the mail archive of the gcc-bugs@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]

[Bug c++/20397] improve diagnostic for 'is inaccessible' error


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20397

--- Comment #19 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Manuel LÃpez-IbÃÃez from comment #18)
> (In reply to Jonathan Wakely from comment #17)
> > FWIW for the original testcase G++ now says:
> > 
> > a.cc:9:8: error: âclass A A::Aâ is inaccessible within this context
> >   int c(A *a) { return 7; }
> >         ^
> 
> Probably we are treating 'A::A' as a type defined in A.  This seems wrong. 

Not really, 'A' is the name of a type, and it is declared in A (as the injected
class name).

> Perhaps enforce_access could use basetype_path to explain why it is
> inaccessible in the same way as Clang does.
> 
> In my ideal world, it would say:
> 
> error: âclass Aâ is inaccessible within this context
>   int c(A *a) { return 7; }
>         ^
> note: constrained by implicitly private inheritance here
> class B : A {
>           ^

I don't like "constrained by implicitly private inheritance", the term
"constrained" is used in other contexts in C++ but not related to access
control.

I think it would be better to say that name lookup found 'A' in the base class
A, where it is inaccessible.

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