summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <merrill@gnu.org>1995-03-02 23:39:09 +0000
committerJason Merrill <merrill@gnu.org>1995-03-02 23:39:09 +0000
commit912b4fc3a4313da6a762d0b0809576729060ff89 (patch)
treeee4c759cff99079d84807cf78958fdfdcfb05226 /gcc
parentf590249e804f57f075bb73c2ebf1e95845af8b2c (diff)
downloadgcc-912b4fc3a4313da6a762d0b0809576729060ff89.tar.gz
(build_binary_op): Avoid spurious warning
| comparing enumerator to unsigned variable. From-SVN: r9113
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-typeck.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index b5cd340fa54..688393f7ae0 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -2443,6 +2443,13 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
tree comp_type = TREE_TYPE (op0);
+ /* Avoid spurious warnings for comparison with enumerators. */
+
+ xop0 = orig_op0;
+ xop1 = orig_op1;
+ STRIP_TYPE_NOPS (xop0);
+ STRIP_TYPE_NOPS (xop1);
+
/* Give warnings for comparisons between signed and unsigned
quantities that may fail. Do not warn if the signed quantity
is an unsuffixed integer literal (or some static constant
@@ -2453,10 +2460,10 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
/* Do the checking based on the original operand trees, so that
casts will be considered, but default promotions won't be. */
if (TREE_UNSIGNED (comp_type)
- && ((op0_signed && (TREE_CODE (orig_op0) != INTEGER_CST
- || tree_int_cst_sgn (orig_op0) == -1))
- || (op1_signed && (TREE_CODE (orig_op1) != INTEGER_CST
- || tree_int_cst_sgn (orig_op1) == -1))))
+ && ((op0_signed && (TREE_CODE (xop0) != INTEGER_CST
+ || tree_int_cst_sgn (xop0) == -1))
+ || (op1_signed && (TREE_CODE (xop1) != INTEGER_CST
+ || tree_int_cst_sgn (xop1) == -1))))
warning ("comparison between signed and unsigned");
}
}