aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-09-09 09:21:09 -0400
committerPatrick Palka <ppalka@redhat.com>2020-09-09 09:21:09 -0400
commit4e03e2e08b94f65f2be3db17f880c205ec262f87 (patch)
tree5374563ac2681eda05b43e4349fcc27042e963c8 /gcc/cp/class.c
parent58905f90434ba9a64abac56324131d67c53910ae (diff)
downloadgcc-4e03e2e08b94f65f2be3db17f880c205ec262f87.zip
gcc-4e03e2e08b94f65f2be3db17f880c205ec262f87.tar.gz
gcc-4e03e2e08b94f65f2be3db17f880c205ec262f87.tar.bz2
c++: Fix resolving the address of overloaded pmf [PR96647]
In resolve_address_of_overloaded_function, currently only the second pass over the overload set (which considers just the function templates in the overload set) checks constraints and performs return type deduction when necessary. But as the testcases below show, we need to do the same when considering non-template functions during the first pass. gcc/cp/ChangeLog: PR c++/96647 * class.c (resolve_address_of_overloaded_function): Check constraints_satisfied_p and perform return-type deduction via maybe_instantiate_decl when considering non-template functions in the overload set. * cp-tree.h (maybe_instantiate_decl): Declare. * decl2.c (maybe_instantiate_decl): Remove static. gcc/testsuite/ChangeLog: PR c++/96647 * g++.dg/cpp0x/auto-96647.C: New test. * g++.dg/cpp0x/error9.C: New test. * g++.dg/cpp2a/concepts-fn6.C: New test.
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 3479b82..c9a1f75 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -8286,6 +8286,19 @@ resolve_address_of_overloaded_function (tree target_type,
one, or vice versa. */
continue;
+ /* Constraints must be satisfied. This is done before
+ return type deduction since that instantiates the
+ function. */
+ if (!constraints_satisfied_p (fn))
+ continue;
+
+ if (undeduced_auto_decl (fn))
+ {
+ /* Force instantiation to do return type deduction. */
+ maybe_instantiate_decl (fn);
+ require_deduced_type (fn);
+ }
+
/* In C++17 we need the noexcept-qualifier to compare types. */
if (flag_noexcept_type
&& !maybe_instantiate_noexcept (fn, complain))