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.
Showing
- gcc/objc/objc-act.c 9 additions, 7 deletionsgcc/objc/objc-act.c
- gcc/objc/objc-next-runtime-abi-02.c 7 additions, 15 deletionsgcc/objc/objc-next-runtime-abi-02.c
- gcc/testsuite/obj-c++.dg/pr101666-0.mm 7 additions, 0 deletionsgcc/testsuite/obj-c++.dg/pr101666-0.mm
- gcc/testsuite/obj-c++.dg/pr101666-1.mm 10 additions, 0 deletionsgcc/testsuite/obj-c++.dg/pr101666-1.mm
- gcc/testsuite/obj-c++.dg/pr101666.inc 29 additions, 0 deletionsgcc/testsuite/obj-c++.dg/pr101666.inc
- gcc/testsuite/objc.dg/pr101666-0.m 7 additions, 0 deletionsgcc/testsuite/objc.dg/pr101666-0.m
- gcc/testsuite/objc.dg/pr101666-1.m 10 additions, 0 deletionsgcc/testsuite/objc.dg/pr101666-1.m
- gcc/testsuite/objc.dg/pr101666.inc 29 additions, 0 deletionsgcc/testsuite/objc.dg/pr101666.inc
Loading
Please register or sign in to comment