* tree.c (tree_expr_nonnegative_p): New function.
* tree.h (tree_expr_nonnegative_p): Declare.
* c-typeck.c (build_binary_op): Call `tree_expr_nonnegative_p' to
elide some sign_compare warnings.
(build_conditional_expr): Likewise.
cp:
* typeck.c (build_binary_op): Call `tree_expr_nonnegative_p' to elide
some sign_compare warnings.
From-SVN: r33019
+2000-04-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * tree.c (tree_expr_nonnegative_p): New function.
+
+ * tree.h (tree_expr_nonnegative_p): Declare.
+
+ * c-typeck.c (build_binary_op): Call `tree_expr_nonnegative_p' to
+ elide some sign_compare warnings.
+ (build_conditional_expr): Likewise.
+
Sat Apr 8 00:21:51 EDT 2000 John Wehle (john@feith.com)
* i386.md (ashrsi3, ashrhi3, ashrqi3): Fix typo.
else
sop = xop1, uop = xop0;
- /* Do not warn if the signed quantity is an unsuffixed
- integer literal (or some static constant expression
- involving such literals) and it is non-negative. */
- if (TREE_CODE (sop) == INTEGER_CST
- && tree_int_cst_sgn (sop) >= 0)
+ /* Do not warn if the signed quantity is an
+ unsuffixed integer literal (or some static
+ constant expression involving such literals or a
+ conditional expression involving such literals)
+ and it is non-negative. */
+ if (tree_expr_nonnegative_p (sop))
/* OK */;
/* Do not warn if the comparison is an equality operation,
the unsigned quantity is an integral constant, and it
/* Do not warn if the signed quantity is an unsuffixed
integer literal (or some static constant expression
involving such literals) and it is non-negative. */
- else if ((unsigned_op2 && TREE_CODE (op1) == INTEGER_CST
- && tree_int_cst_sgn (op1) >= 0)
- || (unsigned_op1 && TREE_CODE (op2) == INTEGER_CST
- && tree_int_cst_sgn (op2) >= 0))
+ else if ((unsigned_op2 && tree_expr_nonnegative_p (op1))
+ || (unsigned_op1 && tree_expr_nonnegative_p (op2)))
/* OK */;
else
warning ("signed and unsigned type in conditional expression");
+2000-04-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * typeck.c (build_binary_op): Call `tree_expr_nonnegative_p' to elide
+ some sign_compare warnings.
+
2000-04-07 Nathan Sidwell <nathan@codesourcery.com>
Rename abi::__vmi_class_type_info members.
/* OK */;
/* Do not warn if the signed quantity is an unsuffixed
integer literal (or some static constant expression
+ involving such literals or a conditional expression
involving such literals) and it is non-negative. */
- else if ((op0_signed && TREE_CODE (orig_op0) == INTEGER_CST
- && tree_int_cst_sgn (orig_op0) >= 0)
- || (op1_signed && TREE_CODE (orig_op1) == INTEGER_CST
- && tree_int_cst_sgn (orig_op1) >= 0))
+ else if ((op0_signed && tree_expr_nonnegative_p (orig_op0))
+ || (op1_signed && tree_expr_nonnegative_p (orig_op1)))
/* OK */;
/* Do not warn if the comparison is an equality operation,
the unsigned quantity is an integral constant and it does
return 1;
}
+/* Return true if `t' is known to be non-negative. */
+
+int
+tree_expr_nonnegative_p (t)
+ tree t;
+{
+ switch (TREE_CODE (t))
+ {
+ case INTEGER_CST:
+ return tree_int_cst_sgn (t) >= 0;
+ case COND_EXPR:
+ return tree_expr_nonnegative_p (TREE_OPERAND (t, 1))
+ && tree_expr_nonnegative_p (TREE_OPERAND (t, 2));
+ default:
+ /* We don't know sign of `t', so be safe and return false. */
+ return 0;
+ }
+}
+
/* Compare two constructor-element-type constants. Return 1 if the lists
are known to be equal; otherwise return 0. */
extern HOST_WIDE_INT tree_low_cst PARAMS ((tree, int));
extern int tree_int_cst_msb PARAMS ((tree));
extern int tree_int_cst_sgn PARAMS ((tree));
+extern int tree_expr_nonnegative_p PARAMS ((tree));
extern int index_type_equal PARAMS ((tree, tree));
extern tree get_inner_array_type PARAMS ((tree));