]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix ICE with xobj parms and maybe incomplete decl-specifiers
authorNathaniel Shead <nathanieloshead@gmail.com>
Sat, 20 Apr 2024 04:44:11 +0000 (14:44 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Tue, 23 Apr 2024 23:24:17 +0000 (09:24 +1000)
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 <nathanieloshead@gmail.com>
gcc/cp/parser.cc
gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C [new file with mode: 0644]

index c23758cf5cf23c34dd9fa03b260e804b109109e4..598380dda089911e99f5d79f7b2c212554b3618b 100644 (file)
@@ -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 (file)
index 0000000..a474e97
--- /dev/null
@@ -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);
+};