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

manu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 21 19:06:00 GMT 2015


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

--- Comment #18 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(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. 

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 {
          ^
fixit: you may use '::A' to access 'class A'
  int c(A *a) { return 7; }
        ^
        ::A
note: 'class A' declared here
class A {
      ^


More information about the Gcc-bugs mailing list