Hi Matt, > On 14 Aug 2021, at 09:14, Matt Jacobson via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > 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. > > Tested by running the frontend against the example in PR101666 and inspecting > the generated code. > > I don't have commit access, so if this patch is suitable, I'd need someone > else > to commit it for me. Thanks.
Thanks for the patch, a couple of requests tho: 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++). thanks Iain > > > 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 e391ee527ce..42645e22316 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); >