aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-02-08 09:11:31 -0500
committerPatrick Palka <ppalka@redhat.com>2022-02-08 09:11:31 -0500
commit676e987b850a7352ece750a8f3a1ac5dae6b3627 (patch)
treeffd4eb991964d6edbab7242bd62edd23cbeee7c2
parent7ff201d85fad11ba6365a5612124b75b385a97bd (diff)
downloadgcc-676e987b850a7352ece750a8f3a1ac5dae6b3627.zip
gcc-676e987b850a7352ece750a8f3a1ac5dae6b3627.tar.gz
gcc-676e987b850a7352ece750a8f3a1ac5dae6b3627.tar.bz2
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.
-rw-r--r--gcc/cp/pt.cc5
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/noexcept-type25.C13
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 5115fba..862f337 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -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;
diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type25.C b/gcc/testsuite/g++.dg/cpp1z/noexcept-type25.C
new file mode 100644
index 0000000..ef5c826
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type25.C
@@ -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));