]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: dependence of member noexcept-spec [PR104079]
authorPatrick Palka <ppalka@redhat.com>
Thu, 3 Feb 2022 23:54:23 +0000 (18:54 -0500)
committerPatrick Palka <ppalka@redhat.com>
Thu, 7 Apr 2022 19:12:38 +0000 (15:12 -0400)
commite95c514cadc4517b7910ead5f8c1dd5b4fd4d991
tree90c5d1a98edf19a8d86c31231e36cc65bf31304d
parent722b23d7a616a92b29826c5bc795c49b2f7775da
c++: dependence of member noexcept-spec [PR104079]

Here a stale TYPE_DEPENDENT_P/_P_VALID value for f's function type
after replacing the type's DEFERRED_NOEXCEPT with the parsed dependent
noexcept-spec causes us to try to instantiate g's noexcept-spec ahead
of time (since it in turn appears non-dependent), leading to an ICE.

This patch fixes this by clearing TYPE_DEPENDENT_P_VALID in
fixup_deferred_exception_variants appropriately (as in
build_cp_fntype_variant).

That turns out to fix the testcase for C++17 but not for C++11/14,
because it's not until C++17 that a noexcept-spec is part of (and
therefore affects dependence of) the function type.  Since dependence of
NOEXCEPT_EXPR is defined in terms of instantiation dependence, the most
appropriate fix for earlier dialects seems to be to make instantiation
dependence consider dependence of a noexcept-spec.

PR c++/104079

gcc/cp/ChangeLog:

* pt.c (value_dependent_noexcept_spec_p): New predicate split
out from ...
(dependent_type_p_r): ... here.
(instantiation_dependent_r): Use value_dependent_noexcept_spec_p
to consider dependence of a noexcept-spec before C++17.
* tree.c (fixup_deferred_exception_variants): Clear
TYPE_DEPENDENT_P_VALID.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept74.C: New test.
* g++.dg/cpp0x/noexcept74a.C: New test.

(cherry picked from commit 82e31c8973eb1a752c2ffd01005efe291d35cee3)
gcc/cp/pt.c
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/noexcept74.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/noexcept74a.C [new file with mode: 0644]