From c750255cace52869888717eef672fc0494dde657 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sun, 18 Feb 2001 00:29:00 +0000 Subject: [PATCH] pt.c (check_explicit_specialization): Copy TREE_PRIVATE and TREE_PROTECTED from the template being specialized. * pt.c (check_explicit_specialization): Copy TREE_PRIVATE and TREE_PROTECTED from the template being specialized. From-SVN: r39813 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 5 +++++ .../g++.old-deja/g++.other/access11.C | 20 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/access11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index efced16555b..e2de97ab4ab 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2001-02-17 Mark Mitchell + + * pt.c (check_explicit_specialization): Copy TREE_PRIVATE and + TREE_PROTECTED from the template being specialized. + 2001-02-17 Jason Merrill * decl2.c (build_artificial_parm): Set TREE_READONLY. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2f34815274b..b28c60a2b5b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 00000000000..04340c74883 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access11.C @@ -0,0 +1,20 @@ +// Build don't link: +// Origin: r.spatschek@fz-juelich.de +// Special g++ Options: -w + +class A +{ +private: + template void g(T t) {} + int i; +}; + +template <> +void A::g(int t) { i = 1; } // ERROR - private + +int main() +{ + A a; + + a.g(0); // ERROR - private +}