]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constrained class template friend [PR93467]
authorPatrick Palka <ppalka@redhat.com>
Thu, 11 Jun 2020 20:33:41 +0000 (16:33 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 11 Jun 2020 20:33:41 +0000 (16:33 -0400)
commit11c7261128ad3ee136508703b20e45cbe04f8dd0
treef50d51ecd1fe46f46e65b4df9dedbcc499604bcd
parentdf665e568dcba2fe0b14a6cf0888cc78b4ebbf44
c++: constrained class template friend [PR93467]

This fixes two issues in our handling of constrained class template
friend declarations.

The first issue is that we fail to set the constraints on the injected
class template declaration during tsubst_friend_class.

The second issue is that the template parameter levels within the parsed
constraints of a class template friend declaration are shifted if the
enclosing class is a template, and this shift leads to spurious
constraint mismatch errors in associate_classtype_constraints if the
friend declaration refers to an already declared class template.

gcc/cp/ChangeLog:

PR c++/93467
* constraint.cc (associate_classtype_constraints): If there is a
discrepancy between the current template depth and the template
depth of the original declaration, then adjust the template
parameter depth within the current constraints appropriately.
* pt.c (tsubst_friend_class): Substitute into and set the
constraints on the injected declaration.

gcc/testsuite/ChangeLog:

PR c++/93467
* g++.dg/cpp2a/concepts-friend6.C: New test.
* g++.dg/cpp2a/concepts-friend7.C: New test.
gcc/cp/constraint.cc
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/concepts-friend6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-friend7.C [new file with mode: 0644]