> On Aug 14, 2021, at 5:25 AM, Iain Sandoe <idsan...@googlemail.com> wrote: > > 1/ please can you either post using a mailer that doesn’t mangle patches or > put the patch as a plain text attachment > (pushing to a git branch somewhere public also works for me, but maybe not > for all reviewers) > - for small patches like this I can obviously fix things up by hand, but > for anything larger not a good idea. > > 2/ since this is fixing a crashing case, we should add a test to the test > suite for it (and also check the corresponding objective-c++). Sorry for the broken patch. I *think* this one should apply cleanly. If not, I’ve also pushed the change to branch "objc-fix-struct-nil-check-10.3.0” of <g...@github.com:mhjacobson/gcc.git>, viewable at: <https://github.com/mhjacobson/gcc/commit/5f158dc5f15fcbeae6163cc46cc520df8369681e> I’ve also added a test specifically for this bug and in the process added -fobjc-nilcheck to the compiler invocation in objc-torture.exp. Let me know what you think. I’m not sure what you mean w.r.t. Objective-C++ -- can you explain? gcc/testsuite/ChangeLog: 2021-08-14 Matt Jacobson <mhjacob...@me.com> PR objc/101666 * lib/objc-torture.exp: Test -fobjc-nilcheck when supported by target. * objc/compile/pr101666.m: New test. gcc/objc/ChangeLog: 2021-08-14 Matt Jacobson <mhjacob...@me.com> PR objc/101666 * objc-next-runtime-abi-02.c (build_v2_objc_method_fixup_call): Fix crash. (build_v2_build_objc_method_call): Fix crash. diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 66c13ad0db2..192731ff954 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -1676,11 +1676,7 @@ build_v2_objc_method_fixup_call (int super_flag, tree method_prototype, if (TREE_CODE (ret_type) == RECORD_TYPE || TREE_CODE (ret_type) == UNION_TYPE) { - vec<constructor_elt, va_gc> *rtt = NULL; - /* ??? CHECKME. hmmm..... think we need something more - here. */ - CONSTRUCTOR_APPEND_ELT (rtt, NULL_TREE, NULL_TREE); - ftree = objc_build_constructor (ret_type, rtt); + ftree = objc_build_constructor (ret_type, NULL); } else ftree = fold_convert (ret_type, integer_zero_node); @@ -1790,11 +1786,7 @@ build_v2_build_objc_method_call (int super, tree method_prototype, if (TREE_CODE (ret_type) == RECORD_TYPE || TREE_CODE (ret_type) == UNION_TYPE) { - vec<constructor_elt, va_gc> *rtt = NULL; - /* ??? CHECKME. hmmm..... think we need something more - here. */ - CONSTRUCTOR_APPEND_ELT (rtt, NULL_TREE, NULL_TREE); - ftree = objc_build_constructor (ret_type, rtt); + ftree = objc_build_constructor (ret_type, NULL); } else ftree = fold_convert (ret_type, integer_zero_node); diff --git a/gcc/testsuite/lib/objc-torture.exp b/gcc/testsuite/lib/objc-torture.exp index 9aa5792f656..58c4b86f840 100644 --- a/gcc/testsuite/lib/objc-torture.exp +++ b/gcc/testsuite/lib/objc-torture.exp @@ -30,7 +30,11 @@ proc objc-set-runtime-options { dowhat args } { # that Darwin uses. If NeXT is ported to another target, then it should # be listed here. if [istarget *-*-darwin*] { - lappend rtlist "-fnext-runtime" + if { [istarget *64-*-*] || [istarget arm-*-*] } { + lappend rtlist "-fnext-runtime -fobjc-abi-version=2 -fobjc-nilcheck" + } else { + lappend rtlist "-fnext-runtime -fobjc-abi-version=1" + } } if [info exists OBJC_RUNTIME_OPTIONS] { foreach other $OBJC_RUNTIME_OPTIONS { diff --git a/gcc/testsuite/objc/compile/pr101666.m b/gcc/testsuite/objc/compile/pr101666.m new file mode 100644 index 00000000000..bfde52d3b35 --- /dev/null +++ b/gcc/testsuite/objc/compile/pr101666.m @@ -0,0 +1,15 @@ +struct point { double x, y, z; }; + +@interface Foo + +- (struct point)bar; + +@end + +Foo *f; + +int +main(void) +{ + struct point p = [f bar]; +}
Re: [PATCH] Objective-C: fix crash with -fobjc-nilcheck
Matt Jacobson via Gcc-patches Sat, 14 Aug 2021 18:13:05 -0700
- [PATCH] Objective-C: fix crash with -fobjc-n... Matt Jacobson via Gcc-patches
- Re: [PATCH] Objective-C: fix crash with... Iain Sandoe via Gcc-patches
- Re: [PATCH] Objective-C: fix crash ... Matt Jacobson via Gcc-patches