diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-02-03 18:54:23 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-02-03 18:54:23 -0500 |
commit | 82e31c8973eb1a752c2ffd01005efe291d35cee3 (patch) | |
tree | f7539fe6e73b907c3edab5be373b8424bb597d1b /gcc/cp/tree.cc | |
parent | 3ef328c293a336df0aead2d72c0c5ed9781a9861 (diff) | |
download | gcc-82e31c8973eb1a752c2ffd01005efe291d35cee3.zip gcc-82e31c8973eb1a752c2ffd01005efe291d35cee3.tar.gz gcc-82e31c8973eb1a752c2ffd01005efe291d35cee3.tar.bz2 |
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.cc (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.cc (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.
Diffstat (limited to 'gcc/cp/tree.cc')
-rw-r--r-- | gcc/cp/tree.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index 056f10f..2d8f2c5 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -2839,6 +2839,10 @@ fixup_deferred_exception_variants (tree type, tree raises) } else TYPE_RAISES_EXCEPTIONS (variant) = raises; + + if (!TYPE_DEPENDENT_P (variant)) + /* We no longer know that it's not type-dependent. */ + TYPE_DEPENDENT_P_VALID (variant) = false; } } |