aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/rtti.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-02-19 20:16:31 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2016-02-19 20:16:31 +0100
commit7a965d512188e997ab9f0f35e9d4b287ca46919c (patch)
tree2f2ea14aaad172874557dbe5f5b41eda91d83519 /gcc/cp/rtti.c
parentc464c0db19b07ffa32e1a7fa574335b625ac765f (diff)
downloadgcc-7a965d512188e997ab9f0f35e9d4b287ca46919c.zip
gcc-7a965d512188e997ab9f0f35e9d4b287ca46919c.tar.gz
gcc-7a965d512188e997ab9f0f35e9d4b287ca46919c.tar.bz2
re PR c++/69850 (unnecessary -Wnonnull-compare warning)
PR c++/69850 * rtti.c (ifnonnull): Set TREE_NO_WARNING on the condition, use NE_EXPR instead of EQ_EXPR and swap last two arguments on COND_EXPR. * g++.dg/warn/Wnonnull-compare-4.C: New test. From-SVN: r233568
Diffstat (limited to 'gcc/cp/rtti.c')
-rw-r--r--gcc/cp/rtti.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 69c3905..244c34d 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -507,12 +507,13 @@ get_typeid (tree type, tsubst_flags_t complain)
static tree
ifnonnull (tree test, tree result, tsubst_flags_t complain)
{
- return build3 (COND_EXPR, TREE_TYPE (result),
- build2 (EQ_EXPR, boolean_type_node, test,
- cp_convert (TREE_TYPE (test), nullptr_node,
- complain)),
- cp_convert (TREE_TYPE (result), nullptr_node, complain),
- result);
+ tree cond = build2 (NE_EXPR, boolean_type_node, test,
+ cp_convert (TREE_TYPE (test), nullptr_node, complain));
+ /* This is a compiler generated comparison, don't emit
+ e.g. -Wnonnull-compare warning for it. */
+ TREE_NO_WARNING (cond) = 1;
+ return build3 (COND_EXPR, TREE_TYPE (result), cond, result,
+ cp_convert (TREE_TYPE (result), nullptr_node, complain));
}
/* Execute a dynamic cast, as described in section 5.2.6 of the 9/93 working