[PATCH] Add fix-it hint for missing return statement in assignment operators (PR c++/85523)

David Malcolm dmalcolm@redhat.com
Fri Aug 3 18:41:00 GMT 2018


On Tue, 2018-05-01 at 07:18 -0400, Nathan Sidwell wrote:
> On 04/30/2018 08:29 PM, David Malcolm wrote:
> > Following on from the thread on the "gcc" list here:
> > 
> >    https://gcc.gnu.org/ml/gcc/2018-04/msg00172.html
> > 
> > here's an updated version of Jonathan's patch, which:
> > +	{
> > +	  tree valtype = TREE_TYPE (DECL_RESULT (fndecl));
> > +	  if (TREE_CODE (valtype) == REFERENCE_TYPE
> > +	      && same_type_ignoring_top_level_qualifiers_p
> > +		  (TREE_TYPE (valtype), TREE_TYPE
> > (current_class_ref)))
> 
> While this is probably close enough, you could
> *) use convert_to_base to include cases where the return type's a
> base 
> of the current object.
> *) convert_to_base would also allow dropping the REFERENCE_TYPE
> check 
> here, so icky code returning by-value could also be caught.
> 
> Up to you.  But otherwise ok.

Sorry about the belated response; this fell off my radar for some
reason.

I looked at updating it to support the cases you suggest, but I wasn't
happy with issuing the fix-it hint for them, so I've gone with the
patch as-is.

Committed to trunk as r263298 (after rebasing and re-testing)

Thanks
Dave



More information about the Gcc-patches mailing list