c++: deducing only from noexcept-spec [PR80951]

The "fail-fast" predicate uses_deducible_template_parms used by
unify_one_argument is neglecting to look inside the noexcept-spec of a
function type.  This causes deduction to spuriously fail whenever the
noexcept-spec is the only part of the type which contains a deducible
template parameter.

	PR c++/80951

gcc/cp/ChangeLog:

	* pt.cc (uses_deducible_template_parms): Consider the
	noexcept-spec of a function type.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/noexcept-type25.C: New test.
This commit is contained in:
Patrick Palka 2022-02-08 09:11:31 -05:00
parent 7ff201d85f
commit 676e987b85
2 changed files with 18 additions and 0 deletions

View file

@ -22449,6 +22449,11 @@ uses_deducible_template_parms (tree type)
for (; parm; parm = TREE_CHAIN (parm))
if (uses_deducible_template_parms (TREE_VALUE (parm)))
return true;
if (flag_noexcept_type
&& TYPE_RAISES_EXCEPTIONS (type)
&& TREE_PURPOSE (TYPE_RAISES_EXCEPTIONS (type))
&& deducible_expression (TREE_PURPOSE (TYPE_RAISES_EXCEPTIONS (type))))
return true;
}
return false;

View file

@ -0,0 +1,13 @@
// PR c++/80951
// { dg-do compile { target c++17 } }
void f() noexcept;
void g();
template<bool E>
constexpr bool h(void (*)() noexcept(E)) {
return E;
}
static_assert(h(f));
static_assert(!h(g));