diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-02-19 17:02:51 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-02-19 17:02:51 +0100 |
commit | 03a616ac3662234f556ff7267d25ba842b7b5bab (patch) | |
tree | de8388c3ac87b258351381e846f5a46652d15ea2 /gcc/cp/init.c | |
parent | 19e2158623cf45a9c9ea731957bea6c3de4a4e56 (diff) | |
download | gcc-03a616ac3662234f556ff7267d25ba842b7b5bab.zip gcc-03a616ac3662234f556ff7267d25ba842b7b5bab.tar.gz gcc-03a616ac3662234f556ff7267d25ba842b7b5bab.tar.bz2 |
re PR c++/69850 (unnecessary -Wnonnull-compare warning)
PR c++/69850
* init.c (build_vec_delete_1): Set TREE_NO_WARNING on the NE_EXPR
condition.
* cp-gimplify.c (cp_fold): Propagate TREE_NO_WARNING from binary
operators if folding preserved the binop, just with different
arguments.
* g++.dg/warn/Wnonnull-compare-2.C: New test.
* g++.dg/warn/Wnonnull-compare-3.C: New test.
From-SVN: r233561
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 68cc1a7..19279e3 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3678,12 +3678,15 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, body = integer_zero_node; /* Outermost wrapper: If pointer is null, punt. */ + tree cond + = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, base, + fold_convert (TREE_TYPE (base), nullptr_node)); + /* This is a compiler generated comparison, don't emit + e.g. -Wnonnull-compare warning for it. */ + if (TREE_CODE (cond) == NE_EXPR) + TREE_NO_WARNING (cond) = 1; body = fold_build3_loc (input_location, COND_EXPR, void_type_node, - fold_build2_loc (input_location, - NE_EXPR, boolean_type_node, base, - fold_convert (TREE_TYPE (base), - nullptr_node)), - body, integer_zero_node); + cond, body, integer_zero_node); body = build1 (NOP_EXPR, void_type_node, body); if (controller) |