diff options
author | Marek Polacek <polacek@redhat.com> | 2024-01-16 15:49:46 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2024-01-16 17:05:09 -0500 |
commit | ac219d524ace47eea5bf5404b267e22950f44030 (patch) | |
tree | a69ed95a9cf6d83874625355c5d5ba0c77592273 /gcc/cp | |
parent | 6a6f338c1cbfc2585cd85358a83e601fb959445e (diff) | |
download | gcc-ac219d524ace47eea5bf5404b267e22950f44030.zip gcc-ac219d524ace47eea5bf5404b267e22950f44030.tar.gz gcc-ac219d524ace47eea5bf5404b267e22950f44030.tar.bz2 |
c++: fix ICE with xobj in destructor [PR113340]
Here we crash in maybe_retrofit_in_chrg on an invalid dtor
with explicit this. Such member functions do not get converted
to METHOD_TYPE. If a dtor gets parameters, we reset arg_types
to void_list_node in grokdeclarator. This results in m_r_in_c
receiving:
void <T8d> (void)
and crashing on
parms = DECL_CHAIN (DECL_ARGUMENTS (fn));
This patch avoids the ICE by resetting is_xobj_member_function after
emitting the error. Then m_r_in_c gets
void S::<T40b> (struct S *)
which does not cause a crash.
PR c++/113340
gcc/cp/ChangeLog:
* decl.cc (grokdeclarator) <case cdk_function>: Clear
is_xobj_member_function in case of an error.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/explicit-obj-diagnostics9.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/decl.cc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index b10a72a..2e57029 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -13743,6 +13743,7 @@ grokdeclarator (const cp_declarator *declarator, "destructors may not have parameters"); arg_types = void_list_node; parms = NULL_TREE; + is_xobj_member_function = false; } type = build_function_type (type, arg_types); |