c++: ICE with operator delete [PR104846]
commitac8310dd122172bf9d7217e3367da55f9bf9b21b
authorMarek Polacek <polacek@redhat.com>
Wed, 9 Mar 2022 16:23:15 +0000 (9 11:23 -0500)
committerMarek Polacek <polacek@redhat.com>
Thu, 10 Mar 2022 14:31:34 +0000 (10 09:31 -0500)
tree0a8305611b9ec38fbf3ad7e08755f5b8e18d6fb1
parente46843ff75c37c705811e0c13bb469eda13b5f6c
c++: ICE with operator delete [PR104846]

This is an ICE-on-invalid with "auto operator delete[] (void *)" whose
return type must be void.  The return type is checked in coerce_delete_type
but we never got there in this test, because we took the wrong path in
grokdeclarator, set type to error_mark_node, ended up creating a FIELD_DECL
with build_decl, and confused grokmethod by giving it a FIELD_DECL.

Fixed by not taking the data member path for a FUNCTION_TYPE.

PR c++/104846

gcc/cp/ChangeLog:

* decl.cc (grokdeclarator): Check FUNC_OR_METHOD_TYPE_P before giving
data member errors.

gcc/testsuite/ChangeLog:

* g++.dg/init/delete5.C: New test.
gcc/cp/decl.cc
gcc/testsuite/g++.dg/init/delete5.C [new file with mode: 0644]