c++: deducing from class type of NTTP [PR105110]
authorPatrick Palka <ppalka@redhat.com>
Fri, 1 Apr 2022 18:56:20 +0000 (14:56 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 1 Apr 2022 18:56:20 +0000 (14:56 -0400)
commit95533fe4f014c10dd18de649927668aba6117daf
tree0b223d19b1c4bb27635bbea774bc99652fe3f9f0
parente9ea121da7d0c6ee7214ca74f861fa5f4bc16913
c++: deducing from class type of NTTP [PR105110]

Here when attempting to deduce T in the NTTP type A<T> from the argument
type 'const A<int>', we give up due to the const:

  types ‘A<T>’ and ‘const A<int>’ have incompatible cv-qualifiers

But since the type of an NTTP cannot be cv-qualified, it seems natural
to ignore cv-qualifiers on the argument type before attempting to unify
the two types.

PR c++/105110

gcc/cp/ChangeLog:

* pt.cc (unify) <case TEMPLATE_PARM_INDEX>: Drop cv-quals from
the argument type of an NTTP before deducing from it.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class52.C: New test.
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp2a/nontype-class52.C [new file with mode: 0644]