c++: Explain fn template argument type/value mismatches [PR66439]
authorPatrick Palka <ppalka@redhat.com>
Tue, 19 May 2020 03:50:14 +0000 (23:50 -0400)
committerPatrick Palka <ppalka@redhat.com>
Tue, 19 May 2020 03:50:14 +0000 (23:50 -0400)
commit864fed4a491606a7b17325d847e1d723d2a44104
tree6b49a44d1ceb3f97e39ca32235262225c1fcfdf9
parent489fb00b14d43ee70d9a0f82f6525d7ffd34e065
c++: Explain fn template argument type/value mismatches [PR66439]

In fn_type_unifcation, we are passing NULL_TREE as the 'in_decl'
parameter to coerce_template_parms, and this is causing template
type/value mismatch error messages to get suppressed regardless of the
value of 'complain'.

This means that when substitution into a function template fails due to
a type/value mismatch between a template parameter and the provided
template argument, we just say "template argument deduction/substitution
failed:" without a followup explanation of the failure.

Fix this by passing 'fn' instead of NULL_TREE to coerce_template_parms.

gcc/cp/ChangeLog:

PR c++/66439
* pt.c (fn_type_unification): Pass 'fn' instead of NULL_TREE as
the 'in_decl' parameter to coerce_template_parms.

gcc/testsuite/ChangeLog:

PR c++/66439
* g++.dg/cpp2a/concepts-ts4.C: Expect a "type/value mismatch"
diagnostic.
* g++.dg/cpp2a/concepts-ts6.C: Likewise.
* g++.dg/template/error56.C: Likewise.
* g++.dg/template/error59.C: New test.

libstdc++-v3/ChangeLog:

PR c++/66439
* testsuite/20_util/pair/astuple/get_neg.cc: Prune "type/value
mismatch" messages.
* testsuite/20_util/tuple/element_access/get_neg.cc: Likewise.
gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/concepts-ts4.C
gcc/testsuite/g++.dg/cpp2a/concepts-ts6.C
gcc/testsuite/g++.dg/template/error56.C
gcc/testsuite/g++.dg/template/error59.C [new file with mode: 0644]
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/20_util/pair/astuple/get_neg.cc
libstdc++-v3/testsuite/20_util/tuple/element_access/get_neg.cc