diff options
author | Martin Sebor <msebor@redhat.com> | 2021-05-20 13:15:58 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-05-20 13:15:58 -0600 |
commit | 9480491a6447576e8e695b8ea3c4989cf72c9670 (patch) | |
tree | 4aa6059ccc5ee54808ce0f11b5c9036dfd0c75e9 /gcc/tree-ssa-ccp.c | |
parent | 4f4a2f199baf46d35492edadc16f30f32920c4df (diff) | |
download | gcc-9480491a6447576e8e695b8ea3c4989cf72c9670.zip gcc-9480491a6447576e8e695b8ea3c4989cf72c9670.tar.gz gcc-9480491a6447576e8e695b8ea3c4989cf72c9670.tar.bz2 |
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): Handle C++ lambda.
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.
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index bf31f03..3834212 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -3536,6 +3536,7 @@ pass_post_ipa_warn::execute (function *fun) continue; tree fndecl = gimple_call_fndecl (stmt); + const bool closure = fndecl && DECL_LAMBDA_FUNCTION_P (fndecl); for (unsigned i = 0; i < gimple_call_num_args (stmt); i++) { @@ -3544,6 +3545,9 @@ pass_post_ipa_warn::execute (function *fun) continue; if (!integer_zerop (arg)) continue; + if (i == 0 && closure) + /* Avoid warning for the first argument to lambda functions. */ + continue; if (!bitmap_empty_p (nonnullargs) && !bitmap_bit_p (nonnullargs, i)) continue; |