+2016-10-05 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ * c-common.c (c_common_truthvalue_conversion): Warn also for suspicious
+ conditional expression in boolean context when only one arm is
+ non-boolean.
+
2016-10-05 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/77823
warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
"?: using integer constants in boolean context, "
"the expression will always evaluate to %<true%>");
+ else if ((TREE_CODE (val1) == INTEGER_CST
+ && !integer_zerop (val1)
+ && !integer_onep (val1))
+ || (TREE_CODE (val2) == INTEGER_CST
+ && !integer_zerop (val2)
+ && !integer_onep (val2)))
+ warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
+ "?: using integer constants in boolean context");
}
/* Distribute the conversion into the arms of a COND_EXPR. */
if (c_dialect_cxx ())
+2016-10-05 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ * c-c++-common/Wint-in-bool-context.c: Update test.
+
2016-10-05 Marek Polacek <polacek@redhat.com>
* g++.dg/cpp1z/init-statement1.C: New test.
if (a > 0 && a <= (b == 2) ? 1 : 1) /* { dg-bogus "boolean context" } */
return 2;
- if (a > 0 && a <= (b == 3) ? 0 : 2) /* { dg-bogus "boolean context" } */
+ if (a > 0 && a <= (b == 3) ? 0 : 2) /* { dg-warning "boolean context" } */
return 3;
if (a == b ? 0 : 0) /* { dg-bogus "boolean context" } */