+2017-08-30 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ 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 <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
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
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;
--- /dev/null
+// { dg-do compile { target c++11 } }
+
+template <typename>
+struct is_function {
+ static constexpr bool value = false;
+};
+
+template <typename R, typename ...Args>
+struct is_function<R(Args...)>
+{
+ static constexpr bool value = true;
+};
+
+template<bool, typename> struct enable_if {};
+
+template<typename T> struct enable_if<true, T>
+{
+ typedef T type;
+};
+
+template <class T>
+struct remove_pointer
+{
+ typedef T type;
+};
+
+template <class T>
+struct remove_pointer<T*>
+{
+ typedef T type;
+};
+
+void f(int) {}
+void f(double) {}
+
+template <class T>
+struct X
+{
+ template <class U=T,
+ typename enable_if<is_function<
+ typename remove_pointer<U>::type>::value,
+ bool>::type = false> X(U&&) {}
+};
+
+int main() {
+ X<void(*)(int)> x0(f);
+}