From 40c44f13de1ac037a120636d569933155f5e5af7 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 25 May 2011 01:08:46 +0000 Subject: [PATCH] PR c++/48884 * pt.c (fn_type_unification): Disable access control during substitution. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174163 138bc75d-0d04-0410-961f-82ee72b054a4 index c8eb1d5..e7040c1 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13743,7 +13743,9 @@ fn_type_unification (tree fn, incomplete = NUM_TMPL_ARGS (explicit_targs) != NUM_TMPL_ARGS (targs); processing_template_decl += incomplete; + push_deferring_access_checks (dk_no_check); fntype = tsubst (fntype, converted_args, tf_none, NULL_TREE); + pop_deferring_access_checks (); processing_template_decl -= incomplete; if (fntype == error_mark_node) @@ -13830,7 +13832,10 @@ fn_type_unification (tree fn, substitution results in an invalid type, as described above, type deduction fails. */ { - tree substed = tsubst (TREE_TYPE (fn), targs, tf_none, NULL_TREE); + tree substed; + push_deferring_access_checks (dk_no_check); + substed = tsubst (TREE_TYPE (fn), targs, tf_none, NULL_TREE); + pop_deferring_access_checks (); if (substed == error_mark_node) return 1; new file mode 100644 index 0000000..8414c43 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/access21.C @@ -0,0 +1,23 @@ +// PR c++/48884 + +class X +{ + static const int I = 42; + friend struct Y; +}; + +template struct A { }; + +struct Y +{ + template + static A f(T t) + { + return A(); + } +}; + +int main() +{ + Y::f(X()); +} diff --git a/gcc/testsuite/g++.dg/template/access22.C b/gcc/testsuite/g++.dg/template/access22.C new file mode 100644 index 0000000..9ee28a2 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/access22.C @@ -0,0 +1,15 @@ +template struct B { }; + +template +B f(); + +class A +{ + static const int I = 42; + template friend B f(); +}; + +int main() +{ + f(); +} -- 1.7.0.4