]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/66957 (incorrect "is protected within this context" error)
authorJason Merrill <jason@redhat.com>
Tue, 18 Aug 2015 14:43:44 +0000 (10:43 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 18 Aug 2015 14:43:44 +0000 (10:43 -0400)
PR c++/66957
* search.c (protected_accessible_p): Revert fix for 38579.

From-SVN: r226974

gcc/cp/ChangeLog
gcc/cp/search.c
gcc/testsuite/g++.dg/conversion/access1.C
gcc/testsuite/g++.dg/inherit/access9.C [new file with mode: 0644]

index 4e239fa13c0188b8398febc9c284e11ad58196d8..8fe4ac59b5f3f7f43426251d742b1f1db7924237 100644 (file)
@@ -1,5 +1,8 @@
 2015-08-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/66957
+       * search.c (protected_accessible_p): Revert fix for 38579.
+
        PR c++/58063
        * tree.c (bot_manip): Remap SAVE_EXPR.
 
index c3eed90f6c3632b5a9ade786e0c09e3a2444131d..0b3059849c5f3b9b6485681a076b8b87524e5038 100644 (file)
@@ -727,7 +727,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);
index f187e63a9d3d9aecd3480b463f6142499c8698d2..6ed063aa158f1d034824fbab478f839d9d47f0e6 100644 (file)
@@ -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 (file)
index 0000000..cdbc640
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/66957
+
+class BaseClass {
+protected:
+  static int x;
+};
+
+struct DerivedA : BaseClass { };
+
+struct DerivedB : BaseClass {
+  DerivedB() {
+    (void) DerivedA::x;
+  }
+};