public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-919] c++: auto function as function argument [PR105779]
@ 2022-06-01 19:21 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-06-01 19:21 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:72e52b88582e738c8b8bde5f85af63d3a0e15d2b
commit r13-919-g72e52b88582e738c8b8bde5f85af63d3a0e15d2b
Author: Jason Merrill <jason@redhat.com>
Date: Tue May 31 16:17:58 2022 -0400
c++: auto function as function argument [PR105779]
This testcase demonstrates that the issue in PR105623 is not limited to
templates, so we should do the marking in a less template-specific place.
PR c++/105779
gcc/cp/ChangeLog:
* call.cc (resolve_args): Call mark_single_function here.
* pt.cc (unify_one_argument): Not here.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/auto-fn63.C: New test.
Diff:
---
gcc/cp/call.cc | 5 +++++
gcc/cp/pt.cc | 4 ----
gcc/testsuite/g++.dg/cpp1y/auto-fn63.C | 12 ++++++++++++
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 85fe9b5ab85..4710c3777c5 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -4672,6 +4672,11 @@ resolve_args (vec<tree, va_gc> *args, tsubst_flags_t complain)
}
else if (invalid_nonstatic_memfn_p (EXPR_LOCATION (arg), arg, complain))
return NULL;
+
+ /* Force auto deduction now. Omit tf_warning to avoid redundant
+ deprecated warning on deprecated-14.C. */
+ if (!mark_single_function (arg, tf_error))
+ return NULL;
}
return args;
}
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 4f0ace2644b..6de8e496859 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -22624,10 +22624,6 @@ unify_one_argument (tree tparms, tree targs, tree parm, tree arg,
return unify_success (explain_p);
}
- /* Force auto deduction now. Use tf_none to avoid redundant
- deprecated warning on deprecated-14.C. */
- mark_single_function (arg, tf_none);
-
arg_expr = arg;
arg = unlowered_expr_type (arg);
if (arg == error_mark_node)
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn63.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn63.C
new file mode 100644
index 00000000000..ca3bc854065
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn63.C
@@ -0,0 +1,12 @@
+// PR c++/105779
+// { dg-do compile { target c++14 } }
+
+template<int>
+struct struct1
+{
+ static auto apply() { return 1; }
+};
+
+int method(int(*f)());
+
+int t = method(struct1<1>::apply);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-01 19:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 19:21 [gcc r13-919] c++: auto function as function argument [PR105779] Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).