2016-02-23 Jakub Jelinek <jakub@redhat.com>
+ PR c++/69902
+ * fold-const.c (fold_truth_not_expr): Propagate TREE_NO_WARNING
+ when inverting comparison.
+
PR c/69900
* common.opt (Wunreachable-code): Add Warning flag.
if (code == ERROR_MARK)
return NULL_TREE;
- return build2_loc (loc, code, type, TREE_OPERAND (arg, 0),
- TREE_OPERAND (arg, 1));
+ tree ret = build2_loc (loc, code, type, TREE_OPERAND (arg, 0),
+ TREE_OPERAND (arg, 1));
+ if (TREE_NO_WARNING (arg))
+ TREE_NO_WARNING (ret) = 1;
+ return ret;
}
switch (code)
--- /dev/null
+// PR c++/69902
+// { dg-do compile }
+// { dg-options "-Wall" }
+
+struct A { virtual ~A (); };
+struct B : A {};
+
+bool
+foo (A &a)
+{
+ return dynamic_cast<B *>(&a) == (B *) 0; // { dg-bogus "nonnull argument" }
+}
+
+bool
+bar (A &a)
+{
+ return dynamic_cast<B *>(&a) != (B *) 0; // { dg-bogus "nonnull argument" }
+}