c++: Refinements to "more constrained".
authorJason Merrill <jason@redhat.com>
Fri, 12 Jun 2020 03:58:54 +0000 (23:58 -0400)
committerJason Merrill <jason@redhat.com>
Sat, 20 Jun 2020 14:57:21 +0000 (10:57 -0400)
commit57b4daf8dc4ed7b669cc70638866ddb00f5b7746
tree25aa1fbdf05d421d0589bb95b9ecbb5bba6e74de
parent3345e74299687de6144b87c0632018cafd4ccf3b
c++: Refinements to "more constrained".

P2113 from the last C++ meeting clarified that we only compare constraints
on functions or function templates that have equivalent template parameters
and function parameters.

I'm not currently implementing the complicated handling of reversed
comparison operators here; thinking about it now, it seems like a lot of
complexity to support a very weird usage.  If I write two similar comparison
operators to be distinguished by their constraints, why would I write one
reversed?  If they're two unrelated operators, they're very unlikely to be
similar enough for the complexity to help.  I've started a discussion on the
committee reflector about changing these rules.

This change breaks some greedy_ops tests in libstdc++ that were relying on
comparing constraints on unrelated templates, which seems pretty clearly
wrong, so I'm removing those tests for now.

gcc/cp/ChangeLog:

* call.c (joust): Only compare constraints for non-template
candidates with matching parameters.
* pt.c (tsubst_pack_expansion): Fix getting a type parameter
pack.
(more_specialized_fn): Only compare constraints for candidates with
matching parameters.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-return-req1.C: Expect error.
* g++.dg/cpp2a/concepts-p2113a.C: New test.
* g++.dg/cpp2a/concepts-p2113b.C: New test.

libstdc++-v3/ChangeLog:

* testsuite/24_iterators/move_iterator/rel_ops_c++20.cc:
Remove greedy_ops tests.
* testsuite/24_iterators/reverse_iterator/rel_ops_c++20.cc:
Remove greedy_ops tests.
gcc/cp/call.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/concepts-p2113a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-p2113b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-return-req1.C
libstdc++-v3/testsuite/24_iterators/move_iterator/rel_ops_c++20.cc
libstdc++-v3/testsuite/24_iterators/reverse_iterator/rel_ops_c++20.cc