From 4149642428e2cffdd0ec2c7d14434b2c40b7de21 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 12 Dec 2013 22:58:48 -0500 Subject: [PATCH] re PR c++/58954 (accessing a private member function in decltype of a friend class causes access control error) PR c++/58954 * pt.c (resolve_overloaded_unification): Use instantiate_template. From-SVN: r205952 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/pt.c | 2 +- gcc/testsuite/g++.dg/cpp0x/access02.C | 39 +++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/access02.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ca4a32113ef..59c1d5322e7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2013-12-12 Jason Merrill + + PR c++/58954 + * pt.c (resolve_overloaded_unification): Use instantiate_template. + 2013-12-12 Jakub Jelinek PR c++/58627 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2c64a71ec0e..d566afdfcc5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16407,7 +16407,7 @@ resolve_overloaded_unification (tree tparms, if (subargs != error_mark_node && !any_dependent_template_arguments_p (subargs)) { - elem = tsubst (TREE_TYPE (fn), subargs, tf_none, NULL_TREE); + elem = TREE_TYPE (instantiate_template (fn, subargs, tf_none)); if (try_one_overload (tparms, targs, tempargs, parm, elem, strict, sub_strict, addr_p, explain_p) && (!goodfn || !same_type_p (goodfn, elem))) diff --git a/gcc/testsuite/g++.dg/cpp0x/access02.C b/gcc/testsuite/g++.dg/cpp0x/access02.C new file mode 100644 index 00000000000..74960a66a61 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/access02.C @@ -0,0 +1,39 @@ +// PR c++/58954 +// { dg-require-effective-target c++11 } + +template +T&& declval(); + +template +struct foo_argument +{ + template + static Arg test(Ret (C::*)(Arg)); + + typedef decltype(test(&T::template foo<>)) type; +}; + +template +struct dependent { typedef T type; }; + +template +struct base +{ + template + auto foo(int i) -> decltype(declval< + typename dependent::type + >().foo_impl(i)); +}; + +struct derived : base +{ + friend struct base; +private: + int foo_impl(int i); +}; + +int main() +{ + foo_argument::type var = 0; + return var; +}