aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2024-01-17 19:16:32 -0500
committerMarek Polacek <polacek@redhat.com>2024-01-18 09:11:57 -0500
commit9840e0be78150b0ef6e29975a6244698d5a5580c (patch)
treed78118d7216f8232ba93043246445fc945e91b0b /gcc/cp
parent1d82a2d933efd49a895873545a46f4945c716654 (diff)
downloadgcc-9840e0be78150b0ef6e29975a6244698d5a5580c.zip
gcc-9840e0be78150b0ef6e29975a6244698d5a5580c.tar.gz
gcc-9840e0be78150b0ef6e29975a6244698d5a5580c.tar.bz2
c++: ICE when xobj is not the first parm [PR113389]
In grokdeclarator/cdk_function the comment says that the find_xobj_parm lambda clears TREE_PURPOSE so that we can correctly detect an xobj that is not the first parameter. That's all good, but we should also clear the TREE_PURPOSE once we've given the error, otherwise we crash later in check_default_argument because the 'this' TREE_PURPOSE lacks a type. PR c++/113389 gcc/cp/ChangeLog: * decl.cc (grokdeclarator) <case cdk_function>: Set TREE_PURPOSE to NULL_TREE when emitting an error. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-diagnostics10.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/decl.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 322e48d..3e41fd4 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -13391,6 +13391,7 @@ grokdeclarator (const cp_declarator *declarator,
if (TREE_PURPOSE (parm) != this_identifier)
continue;
bad_xobj_parm_encountered = true;
+ TREE_PURPOSE (parm) = NULL_TREE;
gcc_rich_location bad_xobj_parm
(DECL_SOURCE_LOCATION (TREE_VALUE (parm)));
error_at (&bad_xobj_parm,