c-common.c (warn_logical_operator): Fix condition.

2007-03-10  Dirk Mueller  <dmueller@suse.de>

       * c-common.c (warn_logical_operator): Fix condition.

From-SVN: r122800
This commit is contained in:
Dirk Mueller 2007-03-10 18:49:28 +00:00 committed by Dirk Mueller
parent 4cdffe3d10
commit 89132ebc4c
2 changed files with 19 additions and 17 deletions

View File

@ -1,3 +1,7 @@
2007-03-10 Dirk Mueller <dmueller@suse.de>
* c-common.c (warn_logical_operator): Fix condition.
2007-03-10 Tobias Schlüter <tobi@gcc.gnu.org>
* config/i386/darwin.h (DARWIN_MINVERSION_SPEC): Add missing

View File

@ -994,24 +994,22 @@ warn_logical_operator (enum tree_code code, tree arg1, tree
case TRUTH_ORIF_EXPR:
case TRUTH_OR_EXPR:
case TRUTH_AND_EXPR:
if (!TREE_NO_WARNING (arg1)
&& INTEGRAL_TYPE_P (TREE_TYPE (arg1))
&& !CONSTANT_CLASS_P (arg1)
&& TREE_CODE (arg2) == INTEGER_CST
&& !integer_zerop (arg2)
&& !integer_onep (arg2))
{
warning (OPT_Wlogical_op,
"logical %<%s%> with non-zero constant "
"will always evaluate as true",
((code == TRUTH_ANDIF_EXPR)
|| (code == TRUTH_AND_EXPR)) ? "&&" : "||");
TREE_NO_WARNING (arg1) = true;
}
break;
if (!TREE_NO_WARNING (arg1)
&& INTEGRAL_TYPE_P (TREE_TYPE (arg1))
&& !CONSTANT_CLASS_P (arg1)
&& TREE_CODE (arg2) == INTEGER_CST
&& !integer_zerop (arg2))
{
warning (OPT_Wlogical_op,
"logical %<%s%> with non-zero constant "
"will always evaluate as true",
((code == TRUTH_ANDIF_EXPR)
|| (code == TRUTH_AND_EXPR)) ? "&&" : "||");
TREE_NO_WARNING (arg1) = true;
}
break;
default:
break;
break;
}
}