c++: Fix ICE with constrained friend (PR93400).
authorJason Merrill <jason@redhat.com>
Fri, 24 Jan 2020 19:58:56 +0000 (14:58 -0500)
committerJason Merrill <jason@redhat.com>
Sat, 25 Jan 2020 06:07:51 +0000 (01:07 -0500)
commit9c1179c339e050e2ce7c545f648b684d38dec69d
treefef82e21680ee056351348a5cc251447eb17b822
parent8b91e848130e45b427599ad30e99f96e447ea9aa
c++: Fix ICE with constrained friend (PR93400).

Here, the problem was that tsubst_friend_function was modifying the
CONSTRAINT_INFO for the friend template to have the constraints for one
instantiation, which fell down when we went to adjust it for another
instantiation.  Fixed by deferring substitution of trailing requirements
until we try to check declaration matching.

PR c++/93400 - ICE with constrained friend.
* constraint.cc (maybe_substitute_reqs_for): New.
* decl.c (function_requirements_equivalent_p): Call it.
* pt.c (tsubst_friend_function): Only substitute
TEMPLATE_PARMS_CONSTRAINTS.
(tsubst_template_parms): Copy constraints.
gcc/cp/ChangeLog
gcc/cp/constraint.cc
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/concepts-friend3.C
gcc/testsuite/g++.dg/cpp2a/concepts-friend5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-pr84140.C