OSDN Git Service

* pt.c (check_explicit_specialization): Copy TREE_PRIVATE and
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Feb 2001 00:29:00 +0000 (00:29 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Feb 2001 00:29:00 +0000 (00:29 +0000)
TREE_PROTECTED from the template being specialized.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39813 138bc75d-0d04-0410-961f-82ee72b054a4

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

index efced16..e2de97a 100644 (file)
@@ -1,3 +1,8 @@
+2001-02-17  Mark Mitchell  <mark@codesourcery.com>
+
+       * pt.c (check_explicit_specialization): Copy TREE_PRIVATE and
+       TREE_PROTECTED from the template being specialized.
+
 2001-02-17  Jason Merrill  <jason@redhat.com>
 
        * decl2.c (build_artificial_parm): Set TREE_READONLY.
index 2f34815..b28c60a 100644 (file)
@@ -1662,6 +1662,11 @@ check_explicit_specialization (declarator, decl, template_count, flags)
             DECL is specializing.  */
          copy_default_args_to_explicit_spec (decl);
 
+         /* This specialization has the same protection as the
+            template it specializes.  */
+         TREE_PRIVATE (decl) = TREE_PRIVATE (gen_tmpl);
+         TREE_PROTECTED (decl) = TREE_PROTECTED (gen_tmpl);
+
          /* Mangle the function name appropriately.  Note that we do
             not mangle specializations of non-template member
             functions of template classes, e.g. with
diff --git a/gcc/testsuite/g++.old-deja/g++.other/access11.C b/gcc/testsuite/g++.old-deja/g++.other/access11.C
new file mode 100644 (file)
index 0000000..04340c7
--- /dev/null
@@ -0,0 +1,20 @@
+// Build don't link:
+// Origin: r.spatschek@fz-juelich.de
+// Special g++ Options: -w
+
+class A
+{
+private:
+  template <class T> void g(T t)  {}
+  int i;
+};
+
+template <>
+void A::g<int>(int t) { i = 1; } // ERROR - private
+
+int main()
+{
+  A a;
+  a.g<int>(0); // ERROR - private
+}