This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] PR c++/32519


Hello,

This patch fixes PR32519. The problem was the use of the macro
DECL_NONSTATIC_MEMBER_P in protected_accessible_p(). this macro does
not return true when TREE_CODE (decl) == TEMPLATE_DECL.

Currently, I have the GNU copyright assignement for GCC but no SVN
write access; so can someone please review the following patch and
commit it for me if correct ?

Thanks.

Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(revision 139914)
+++ gcc/testsuite/ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2008-09-03  Fabien Chene  <fabien.chene@gmail.com>
+	PR c++/32519
+	* g++.dg/template/pr32519.C: New test.
+	
 2008-09-02  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* gcc.target/i386/amd64-abi-3.c: New test.
Index: gcc/testsuite/g++.dg/template/pr32519.C
===================================================================
--- gcc/testsuite/g++.dg/template/pr32519.C	(revision 0)
+++ gcc/testsuite/g++.dg/template/pr32519.C	(revision 0)
@@ -0,0 +1,16 @@
+// PR 32519
+// { dg-do compile }
+
+struct B
+{
+protected:
+  template <class T> void f (); // { dg-error "protected" }
+};
+
+struct D : public B
+{
+  void g (B* b)
+  {
+    b->f<int> (); // { dg-error "context" }
+  }
+};
Index: gcc/cp/search.c
===================================================================
--- gcc/cp/search.c	(revision 139914)
+++ gcc/cp/search.c	(working copy)
@@ -754,7 +754,8 @@ protected_accessible_p (tree decl, tree 
      derived from that class) (_expr.ref_).  If the access is to form
      a pointer to member, the nested-name-specifier shall name the
      derived class (or any class derived from that class).  */
-  if (DECL_NONSTATIC_MEMBER_P (decl))
+  if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)
+      || TREE_CODE (decl) == FIELD_DECL)
     {
       /* We can tell through what the reference is occurring by
 	 chasing BINFO up to the root.  */
Index: gcc/cp/ChangeLog
===================================================================
--- gcc/cp/ChangeLog	(revision 139914)
+++ gcc/cp/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2008-09-03  Fabien Chene  <fabien.chene@gmail.com>
+
+	PR c++/32519
+	* search.c (protected_accessible_p): handle member template
+	functions.
+
 2008-09-01  Aldy Hernandez  <aldyh@redhat.com>
 
 	* typeck.c (build_x_indirect_ref): Add location argument.
--
Fab

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]