diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 404edab76b9c..b935e08d9842 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-08-17 Jason Merrill + + PR c++/66957 + * search.c (protected_accessible_p): Revert fix for 38579. + 2015-08-17 Paolo Carlini PR c++/66919 diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 0031acdd848a..1864f9083665 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -736,7 +736,7 @@ protected_accessible_p (tree decl, tree derived, tree binfo) Here DERIVED is a possible P, DECL is m and BINFO_TYPE (binfo) is N. */ /* If DERIVED isn't derived from N, then it can't be a P. */ - if (!DERIVED_FROM_P (BINFO_TYPE (binfo), derived)) + if (!DERIVED_FROM_P (context_for_name_lookup (decl), derived)) return 0; access = access_in_type (derived, decl); diff --git a/gcc/testsuite/g++.dg/conversion/access1.C b/gcc/testsuite/g++.dg/conversion/access1.C index f187e63a9d3d..6ed063aa158f 100644 --- a/gcc/testsuite/g++.dg/conversion/access1.C +++ b/gcc/testsuite/g++.dg/conversion/access1.C @@ -15,7 +15,7 @@ struct B : protected P struct C : public P { // C can access P's copy ctor, but can't convert b to const P&. - C(const B& b) : P(b) {} // { dg-error "inaccessible base" } + C(const B& b) : P(b) {} // { dg-error "inaccessible base" "" { xfail *-*-* } } }; void foo() diff --git a/gcc/testsuite/g++.dg/inherit/access9.C b/gcc/testsuite/g++.dg/inherit/access9.C new file mode 100644 index 000000000000..cdbc64043933 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/access9.C @@ -0,0 +1,14 @@ +// PR c++/66957 + +class BaseClass { +protected: + static int x; +}; + +struct DerivedA : BaseClass { }; + +struct DerivedB : BaseClass { + DerivedB() { + (void) DerivedA::x; + } +};