From: Ville Voutilainen Date: Wed, 30 Aug 2017 20:50:25 +0000 (+0300) Subject: Make taking the address of an overloaded function a non-deduced context X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=18cb045d873daf1b803b8b3973bafa260d459f41;p=gcc.git Make taking the address of an overloaded function a non-deduced context cp/ * pt.c (unify_overload_resolution_failure): Remove. (unify_one_argument): Adjust. testsuite/ * g++.dg/overload/template6.C: New. From-SVN: r251548 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 69267c0ec35..10ae08ae186 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-08-30 Ville Voutilainen + + Make taking the address of an overloaded function a non-deduced context + + * pt.c (unify_overload_resolution_failure): Remove. + (unify_one_argument): Adjust. + 2017-08-30 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 141b4d7564a..f4868abfda2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6400,16 +6400,6 @@ unify_template_argument_mismatch (bool explain_p, tree parm, tree arg) return unify_invalid (explain_p); } -static int -unify_overload_resolution_failure (bool explain_p, tree arg) -{ - if (explain_p) - inform (input_location, - " could not resolve address from overloaded function %qE", - arg); - return unify_invalid (explain_p); -} - /* Attempt to convert the non-type template parameter EXPR to the indicated TYPE. If the conversion is successful, return the converted value. If the conversion is unsuccessful, return @@ -19305,12 +19295,12 @@ unify_one_argument (tree tparms, tree targs, tree parm, tree arg, templates and at most one of a set of overloaded functions provides a unique match. */ - - if (resolve_overloaded_unification - (tparms, targs, parm, arg, strict, - arg_strict, explain_p)) - return unify_success (explain_p); - return unify_overload_resolution_failure (explain_p, arg); + resolve_overloaded_unification (tparms, targs, parm, + arg, strict, + arg_strict, explain_p); + /* If a unique match was not found, this is a + non-deduced context, so we still succeed. */ + return unify_success (explain_p); } arg_expr = arg; diff --git a/gcc/testsuite/g++.dg/overload/template6.C b/gcc/testsuite/g++.dg/overload/template6.C new file mode 100644 index 00000000000..f2650aacba9 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/template6.C @@ -0,0 +1,47 @@ +// { dg-do compile { target c++11 } } + +template +struct is_function { + static constexpr bool value = false; +}; + +template +struct is_function +{ + static constexpr bool value = true; +}; + +template struct enable_if {}; + +template struct enable_if +{ + typedef T type; +}; + +template +struct remove_pointer +{ + typedef T type; +}; + +template +struct remove_pointer +{ + typedef T type; +}; + +void f(int) {} +void f(double) {} + +template +struct X +{ + template ::type>::value, + bool>::type = false> X(U&&) {} +}; + +int main() { + X x0(f); +}