This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20397] improve diagnostic for 'is inaccessible' error
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 Jul 2015 23:21:52 +0000
- Subject: [Bug c++/20397] improve diagnostic for 'is inaccessible' error
- Auto-submitted: auto-generated
- References: <bug-20397-4 at http dot gcc dot gnu dot org/bugzilla/>
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.