]> gcc.gnu.org Git - gcc.git/commit
Objective-C: fix crash with -fobjc-nilcheck
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 14 Aug 2021 11:27:55 +0000 (12:27 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Wed, 18 Aug 2021 18:41:43 +0000 (19:41 +0100)
commitd2aa4e0b3b5053df8f5853d9ed29022ff0d3ecf6
treeaf7be9b0ba6076f8d448735eb9eff65403a8cc33
parent220c410162ebece4fffa2912ed79e348d3731d77
Objective-C: fix crash with -fobjc-nilcheck

When -fobjc-nilcheck is enabled, messages that result in a struct type should
yield a zero-initialized struct when sent to nil.  Currently, the frontend
crashes when it encounters this situation.  This patch fixes the crash by
generating the tree for the `{}` initializer.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Matt Jacobson <mhjacobson@me.com>
PR objc/101666

gcc/objc/ChangeLog:

* objc-act.c (objc_build_constructor): Handle empty constructor
lists.
* objc-next-runtime-abi-02.c (build_v2_objc_method_fixup_call):
Handle nil receivers.
(build_v2_build_objc_method_call): Likewise.

gcc/testsuite/ChangeLog:

* obj-c++.dg/pr101666-0.mm: New test.
* obj-c++.dg/pr101666-1.mm: New test.
* obj-c++.dg/pr101666.inc: New.
* objc.dg/pr101666-0.m: New test.
* objc.dg/pr101666-1.m: New test.
* objc.dg/pr101666.inc: New.
gcc/objc/objc-act.c
gcc/objc/objc-next-runtime-abi-02.c
gcc/testsuite/obj-c++.dg/pr101666-0.mm [new file with mode: 0644]
gcc/testsuite/obj-c++.dg/pr101666-1.mm [new file with mode: 0644]
gcc/testsuite/obj-c++.dg/pr101666.inc [new file with mode: 0644]
gcc/testsuite/objc.dg/pr101666-0.m [new file with mode: 0644]
gcc/testsuite/objc.dg/pr101666-1.m [new file with mode: 0644]
gcc/testsuite/objc.dg/pr101666.inc [new file with mode: 0644]
This page took 0.058192 seconds and 5 git commands to generate.