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.


Jeff

Reply via email to