[PATCH] avoid -Wnonnull with lambda (PR 100684)
Richard Biener
richard.guenther@gmail.com
Thu May 20 08:03:34 GMT 2021
On Thu, May 20, 2021 at 7:00 AM Jeff Law via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
> On 5/19/2021 3:01 PM, Martin Sebor via Gcc-patches wrote:
> > The front end -Wnonnull handler has code to suppress warning for
> > lambdas with null this pointers but the middle end handler has
> > no corresponding logic. This leads to spurious -Wnonnull in
> > lambda calls that aren't inlined. That might happen at low
> > optimization levels such as -O1 or -Og and with sanitization.
> >
> > The attached patch enhances the middle end -Wnonnull to deal
> > with this case and avoid the false positives.
> >
> > Tested on x86_64-linux.
> >
> > Martin
> >
> > gcc-100684.diff
> >
> > PR middle-end/100684 - spurious -Wnonnull with -O1 on a C++ lambda
> >
> > gcc/ChangeLog:
> >
> > PR middle-end/100684
> > * tree-ssa-ccp.c (pass_post_ipa_warn::execute):
> >
> > gcc/testsuite/ChangeLog:
> >
> > PR middle-end/100684
> > * g++.dg/warn/Wnonnull13.C: New test.
> > * g++.dg/warn/Wnonnull14.C: New test.
> > * g++.dg/warn/Wnonnull15.C: New test.
>
> OK with a ChangeLog entry for the tree-ssa-ccp change.
Note it won't work with LTO because when the lambda type was
introduced it was added to the hashing code but the streaming
only streams the sub-state DECL_IS_OPERATOR_NEW_P rather
than the full FUNCTION_DECL_DECL_TYPE ...
Martin - was this intended? Can you fix it up please? (g:cb50701ec2c7)
Thanks,
Richard.
>
> Jeff
More information about the Gcc-patches
mailing list