diff options
author | Marek Polacek <polacek@redhat.com> | 2025-02-06 08:57:22 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2025-02-07 09:04:17 -0500 |
commit | f5ef1f9e8589697086c8cfea6ad07d56050dde96 (patch) | |
tree | 8e0768bd393d85d80eb73dc0839c61869816ad0a /gcc/c/c-parser.cc | |
parent | 0b2f34ca19edf2b033c90ff378f561429b82a77a (diff) | |
download | gcc-f5ef1f9e8589697086c8cfea6ad07d56050dde96.zip gcc-f5ef1f9e8589697086c8cfea6ad07d56050dde96.tar.gz gcc-f5ef1f9e8589697086c8cfea6ad07d56050dde96.tar.bz2 |
c++: ICE with unparsed noexcept [PR117106]
In a member-specification of a class, a noexcept-specifier is
a complete-class context. Thus we delay parsing until the end of
the class via our DEFERRED_PARSE mechanism; see cp_parser_save_noexcept
and cp_parser_late_noexcept_specifier.
We also attempt to defer instantiation of noexcept-specifiers in order
to reduce the number of instantiations; this is done via DEFERRED_NOEXCEPT.
We can even have both, as in noexcept65.C: a DEFERRED_PARSE wrapped in
DEFERRED_NOEXCEPT, which uses the DEFPARSE_INSTANTIATIONS mechanism.
noexcept65.C works, because when we really need the noexcept, which is
when parsing the body of S::A::A(), the noexcept will have been parsed
already; noexcepts are parsed before bodies of member function.
But in this test we have:
struct A {
int x;
template<class>
void foo() noexcept(noexcept(x)) {}
auto bar() -> decltype(foo<int>()) {} // #1
};
and I think the decltype in #1 needs the unparsed noexcept before it
could have been parsed. clang++ rejects the test and I suppose we
should reject it as well, rather than crashing on a DEFERRED_PARSE
in tsubst_expr.
PR c++/117106
PR c++/118190
gcc/cp/ChangeLog:
* pt.cc (maybe_instantiate_noexcept): Give an error if the noexcept
hasn't been parsed yet.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/noexcept89.C: New test.
* g++.dg/cpp0x/noexcept90.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/c/c-parser.cc')
0 files changed, 0 insertions, 0 deletions