From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7948) id 04626384AB71; Tue, 23 Apr 2024 23:48:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04626384AB71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713916138; bh=kSF3oLJmsLt0srRGUeBhAsoJN5J1RBRicM5tqNBqOGY=; h=From:To:Subject:Date:From; b=q3PF5UkYZZ+7TPu/PBzX3uGnn3WxKRg8jPGgyrppZSi/DtUteZ4JCt7Y7ofVLLcYU bTHKN8Rkj2k/FezNt169GzwqE25DvDu9CUvzKUtCLqwRhVKzNSLnUNqsWg62KBmAcW PsbPNSdYFTCcsPSeHdOD+KLRaQPdZP+iha2frS9E= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Nathaniel Shead To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-10100] c++: Fix ICE with xobj parms and maybe incomplete decl-specifiers X-Act-Checkin: gcc X-Git-Author: Nathaniel Shead X-Git-Refname: refs/heads/master X-Git-Oldrev: 628c2221d38715a64f828e3635317293d150e001 X-Git-Newrev: 7318f1a389769ab540f414fcba743e90051d466b Message-Id: <20240423234858.04626384AB71@sourceware.org> Date: Tue, 23 Apr 2024 23:48:57 +0000 (GMT) List-Id: https://gcc.gnu.org/g:7318f1a389769ab540f414fcba743e90051d466b commit r14-10100-g7318f1a389769ab540f414fcba743e90051d466b Author: Nathaniel Shead Date: Sat Apr 20 14:44:11 2024 +1000 c++: Fix ICE with xobj parms and maybe incomplete decl-specifiers 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 Diff: --- gcc/cp/parser.cc | 5 +++-- gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index c23758cf5cf..598380dda08 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); +};