This is the mail archive of the gcc-bugs@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]

PATCH for access control on member templates.



Turns out we weren't doing access control for member templates.
Here's a fix.  OK?

-- 
Mark Mitchell <mmitchell@usa.net>
http://home.earthlink.net/~mbmitchell
Consulting Services Available

Wed Apr 22 10:51:48 1998  Mark Mitchell  <mmitchell@usa.net>

	* class.c (finish_struct): Set TREE_PRIVATE and TREE_PROTECTED for
	the DECL_RESULTs of a member TEMPLATE_DECL, not just the
	TEMPLATE_DECL.

Index: class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.40
diff -c -p -r1.40 class.c
*** class.c	1998/04/09 20:36:38	1.40
--- class.c	1998/04/22 17:50:10
*************** finish_struct (t, list_of_fieldlists, at
*** 4318,4323 ****
--- 4318,4329 ----
  	  TREE_PRIVATE (x) = access == access_private_node;
  	  TREE_PROTECTED (x) = access == access_protected_node;
  
+ 	  if (TREE_CODE (x) == TEMPLATE_DECL)
+ 	    {
+ 	      TREE_PRIVATE (DECL_RESULT (x)) = TREE_PRIVATE (x);
+ 	      TREE_PROTECTED (DECL_RESULT (x)) = TREE_PROTECTED (x);
+ 	    }
+ 
  	  /* Check for inconsistent use of this name in the class body.
               Enums, types and static vars have already been checked.  */
  	  if (TREE_CODE (x) != TYPE_DECL && TREE_CODE (x) != USING_DECL
Index: ../testsuite/g++.old-deja/g++.pt/memtemp74.C
===================================================================
RCS file: memtemp74.C
diff -N memtemp74.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- memtemp74.C	Wed Apr 22 10:56:36 1998
***************
*** 0 ****
--- 1,21 ----
+ // Build don't link:
+ 
+ template <class T>
+ class S
+ {
+ protected:
+   template <class U>
+   void f(U); // ERROR - is protected
+ 
+ private:
+   template <class U>
+   void g(U); // ERROR - is private
+ };
+ 
+ 
+ void f()
+ {
+   S<double> s;
+   s.f(3); // ERROR - within this context
+   s.g(2.0); // ERROR - within this context
+ }


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