Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 --
This fixes a null dereference issue when decl_specifiers.type is not yet provided. gcc/cp/ChangeLog: * parser.cc (cp_parser_parameter_declaration): Check if decl_specifiers.type is null. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-basic7.C: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com> --- gcc/cp/parser.cc | 5 +++-- gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 50d3ad35b61..97ee2650dc4 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -25780,8 +25780,9 @@ cp_parser_parameter_declaration (cp_parser *parser, } if (xobj_param_p - && (declarator ? declarator->parameter_pack_p - : PACK_EXPANSION_P (decl_specifiers.type))) + && ((declarator && declarator->parameter_pack_p) + || (decl_specifiers.type + && PACK_EXPANSION_P (decl_specifiers.type)))) { location_t xobj_param = make_location (decl_specifiers.locations[ds_this], diff --git a/gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C b/gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C new file mode 100644 index 00000000000..a474e97fc18 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++23 } } + +// Shouldn't ICE +struct S { + void a(this long); + void b(this const long); + void c(this long unsigned); + void c(this signed); +}; -- 2.43.2