diff options
author | Martin Sebor <msebor@redhat.com> | 2021-01-25 12:41:28 -0700 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-01-25 12:41:28 -0700 |
commit | d6f1cf644c45b76a27b6a6869dedaa030e3c7570 (patch) | |
tree | 099882d59ed8681df57417ddd194bc67af3039cf /gcc/cp | |
parent | 7d54cccad332074d5fb81123796239f0f61b11a7 (diff) | |
download | gcc-d6f1cf644c45b76a27b6a6869dedaa030e3c7570.zip gcc-d6f1cf644c45b76a27b6a6869dedaa030e3c7570.tar.gz gcc-d6f1cf644c45b76a27b6a6869dedaa030e3c7570.tar.bz2 |
PR c++/98646 - spurious -Wnonnull calling a member on the result of static_cast
gcc/c-family/ChangeLog:
PR c++/98646
* c-common.c (check_nonnull_arg): Adjust warning text.
gcc/cp/ChangeLog:
PR c++/98646
* cvt.c (cp_fold_convert): Propagate TREE_NO_WARNING.
gcc/ChangeLog:
PR c++/98646
* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Adjust warning text.
gcc/testsuite/ChangeLog:
PR c++/98646
* g++.dg/warn/Wnonnull5.C: Adjust text of an expected warning.
* g++.dg/warn/Wnonnull10.C: New test.
* g++.dg/warn/Wnonnull9.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/cvt.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index f94488b..e809f0e 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -599,11 +599,14 @@ ignore_overflows (tree expr, tree orig) } /* Fold away simple conversions, but make sure TREE_OVERFLOW is set - properly. */ + properly and propagate TREE_NO_WARNING if folding EXPR results + in the same expression code. */ tree cp_fold_convert (tree type, tree expr) { + bool nowarn = TREE_NO_WARNING (expr); + tree conv; if (TREE_TYPE (expr) == type) conv = expr; @@ -626,6 +629,10 @@ cp_fold_convert (tree type, tree expr) conv = fold_convert (type, expr); conv = ignore_overflows (conv, expr); } + + if (nowarn && TREE_CODE (expr) == TREE_CODE (conv)) + TREE_NO_WARNING (conv) = nowarn; + return conv; } |