if (subargs != error_mark_node
&& !any_dependent_template_arguments_p (subargs))
{
- elem = TREE_TYPE (instantiate_template (fn, subargs, tf_none));
+ fn = instantiate_template (fn, subargs, tf_none);
+ if (undeduced_auto_decl (fn))
+ {
+ /* Instantiate the function to deduce its return type. */
+ ++function_depth;
+ instantiate_decl (fn, /*defer*/false, /*class*/false);
+ --function_depth;
+ }
+
+ elem = TREE_TYPE (fn);
if (try_one_overload (tparms, targs, tempargs, parm,
elem, strict, sub_strict, addr_p, explain_p)
&& (!goodfn || !same_type_p (goodfn, elem)))
--- /dev/null
+// PR c++/64194
+// { dg-do compile { target c++14 } }
+
+template <typename T> void g(void (*)(T)) { }
+
+template <typename> auto id(int) { }
+template <typename> auto id(char) { return 0; }
+
+int main() {
+ g(id<int>);
+}