c-common.c (c_common_truthvalue_conversion): Inhibit Wint-in-bool-context warning...
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Wed, 21 Sep 2016 20:14:44 +0000 (20:14 +0000)
committerBernd Edlinger <edlinger@gcc.gnu.org>
Wed, 21 Sep 2016 20:14:44 +0000 (20:14 +0000)
2016-09-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * c-common.c (c_common_truthvalue_conversion): Inhibit
        Wint-in-bool-context warning with from_macro_definition_at.
        Mention the expression will always evaluate to true.

From-SVN: r240331

gcc/c-family/ChangeLog
gcc/c-family/c-common.c

index 7795f9c8d39590464dd5b06c9525b40e6ec89edc..3dfb39f363177029d27237c94b98d6aaeadc0812 100644 (file)
@@ -1,3 +1,9 @@
+2016-09-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       * c-common.c (c_common_truthvalue_conversion): Inhibit
+       Wint-in-bool-context warning with from_macro_definition_at.
+       Mention the expression will always evaluate to true.
+
 2016-09-21  Martin Sebor  <msebor@redhat.com>
 
        PR bootstrap/77676
index d1372a4feea46caa462971227ceafc9688cce5d1..48d8b054451babc8884e23b7d85a234684bc806d 100644 (file)
@@ -4652,7 +4652,8 @@ c_common_truthvalue_conversion (location_t location, tree expr)
                                               TREE_OPERAND (expr, 0));
 
     case COND_EXPR:
-      if (warn_int_in_bool_context)
+      if (warn_int_in_bool_context
+         && !from_macro_definition_at (EXPR_LOCATION (expr)))
        {
          tree val1 = fold_for_warn (TREE_OPERAND (expr, 1));
          tree val2 = fold_for_warn (TREE_OPERAND (expr, 2));
@@ -4663,7 +4664,8 @@ c_common_truthvalue_conversion (location_t location, tree expr)
              && (!integer_onep (val1)
                  || !integer_onep (val2)))
            warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
-                       "?: using integer constants in boolean context");
+                       "?: using integer constants in boolean context, "
+                       "the expression will always evaluate to %<true%>");
        }
       /* Distribute the conversion into the arms of a COND_EXPR.  */
       if (c_dialect_cxx ())