class.c (finish_struct): Set TREE_PRIVATE and TREE_PROTECTED for the DECL_RESULTs...
authorMark Mitchell <mmitchell@usa.net>
Wed, 22 Apr 1998 13:23:32 +0000 (13:23 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 22 Apr 1998 13:23:32 +0000 (13:23 +0000)
* class.c (finish_struct): Set TREE_PRIVATE and TREE_PROTECTED for
the DECL_RESULTs of a member TEMPLATE_DECL, not just the
TEMPLATE_DECL.

From-SVN: r19376

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/g++.old-deja/g++.pt/memtemp74.C [new file with mode: 0644]

index 9e690446789742edb487d3f8b5411e1c2be4fb42..20725d820aeaa91b9dbe9dc7eef99fad9f5a4a7b 100644 (file)
@@ -1,3 +1,9 @@
+Wed Apr 22 13:24: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.
+
 Tue Apr 21 22:00:04 1998  Mark Mitchell  <mmitchell@usa.net>
 
        * errfn.c (cp_thing): Use xrealloc, not xmalloc, to copy memory.
index 5c4be24268afdbae5e337af48d3cf90742361d2d..fc1c675ff78fc1678a5b1f37d27cbad7298f3ac7 100644 (file)
@@ -4318,6 +4318,12 @@ finish_struct (t, list_of_fieldlists, attributes, warn_anon)
          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
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp74.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp74.C
new file mode 100644 (file)
index 0000000..e99103f
--- /dev/null
@@ -0,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
+}