]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/38579 (Template: Wrong inherited copy-ctor visibility)
authorJason Merrill <jason@redhat.com>
Fri, 16 Jan 2009 18:35:28 +0000 (13:35 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 16 Jan 2009 18:35:28 +0000 (13:35 -0500)
        PR c++/38579
        * search.c (protected_accessible_p): N doesn't vary.

From-SVN: r143439

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

index 306867419d861cf8f700ea8e6dcd25df3ec54e10..395873ced6b96929fcafc0fe62665435b9d1f23c 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-16  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38579
+       * search.c (protected_accessible_p): N doesn't vary.
+
 2009-01-15  Jason Merrill  <jason@redhat.com>
 
        PR c++/38850
index 7fc040bc8c47f2368f64d3a3f678c1213713b89c..ecc79264e114e177cdf5935de4fcb2ab0ebeb765 100644 (file)
@@ -721,20 +721,13 @@ protected_accessible_p (tree decl, tree derived, tree binfo)
 
        m as a member of N is protected, and the reference occurs in a
        member or friend of class N, or in a member or friend of a
-       class P derived from N, where m as a member of P is private or
-       protected.
-
-    Here DERIVED is a possible P and DECL is m.  accessible_p will
-    iterate over various values of N, but the access to m in DERIVED
-    does not change.
+       class P derived from N, where m as a member of P is public, private
+       or protected.
 
-    Note that I believe that the passage above is wrong, and should read
-    "...is private or protected or public"; otherwise you get bizarre results
-    whereby a public using-decl can prevent you from accessing a protected
-    member of a base.  (jason 2000/02/28)  */
+    Here DERIVED is a possible P, DECL is m and BINFO_TYPE (binfo) is N.  */
 
-  /* If DERIVED isn't derived from m's class, then it can't be a P.  */
-  if (!DERIVED_FROM_P (context_for_name_lookup (decl), derived))
+  /* If DERIVED isn't derived from N, then it can't be a P.  */
+  if (!DERIVED_FROM_P (BINFO_TYPE (binfo), derived))
     return 0;
 
   access = access_in_type (derived, decl);
index e8a3cc3e5d15f6f5a8e1bf8181ccd672bdc02c64..96b4ce583d73425d9c498bb7e475a474e44f0523 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-16  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38579
+       * g++.dg/conversion/access1.C: New test.
+
 2009-01-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/38789
diff --git a/gcc/testsuite/g++.dg/conversion/access1.C b/gcc/testsuite/g++.dg/conversion/access1.C
new file mode 100644 (file)
index 0000000..f187e63
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/38579
+
+struct P 
+{
+protected:
+  P() {}
+  P(const P&) {}
+};
+
+struct B : protected P
+{
+  B() {}
+};
+
+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" }
+};
+
+void foo()
+{
+  B b;
+  C c(b);
+}