return false;
}
-/* Return true if (CODE OP0) is known to be non-negative. If the return
- value is based on the assumption that signed overflow is undefined,
- set *STRICT_OVERFLOW_P to true; otherwise, don't change
- *STRICT_OVERFLOW_P. DEPTH is the current nesting depth of the query. */
+/* Return true if (CODE OP0) is known to be non-negative.
+ DEPTH is the current nesting depth of the query. */
bool
-tree_unary_nonnegative_warnv_p (enum tree_code code, tree type, tree op0,
- bool *strict_overflow_p, int depth)
+tree_unary_nonnegative_p (enum tree_code code, tree type, tree op0, int depth)
{
if (TYPE_UNSIGNED (type))
return true;
+ /* The RECURSE () macro counts with a strict_overflow_p bool
+ pointer being declared beforehand. */
+ bool val = false;
+ bool *strict_overflow_p = &val;
+
switch (code)
{
case ABS_EXPR:
if (!ANY_INTEGRAL_TYPE_P (type))
return true;
if (TYPE_OVERFLOW_UNDEFINED (type))
- {
- *strict_overflow_p = true;
- return true;
- }
+ return true;
break;
case NON_LVALUE_EXPR:
depth);
case tcc_unary:
- return tree_unary_nonnegative_warnv_p (TREE_CODE (t),
- TREE_TYPE (t),
- TREE_OPERAND (t, 0),
- strict_overflow_p, depth);
+ return tree_unary_nonnegative_p (TREE_CODE (t),
+ TREE_TYPE (t),
+ TREE_OPERAND (t, 0),
+ depth);
case tcc_constant:
case tcc_declaration:
TREE_OPERAND (t, 1),
depth);
case TRUTH_NOT_EXPR:
- return tree_unary_nonnegative_warnv_p (TREE_CODE (t),
- TREE_TYPE (t),
- TREE_OPERAND (t, 0),
- strict_overflow_p, depth);
+ return tree_unary_nonnegative_p (TREE_CODE (t),
+ TREE_TYPE (t),
+ TREE_OPERAND (t, 0),
+ depth);
case COND_EXPR:
case CONSTRUCTOR:
extern bool tree_unary_nonzero_p (enum tree_code, tree, tree);
extern bool tree_binary_nonzero_p (enum tree_code, tree, tree, tree op1);
extern bool tree_single_nonzero_p (tree);
-extern bool tree_unary_nonnegative_warnv_p (enum tree_code, tree, tree,
- bool *, int);
+extern bool tree_unary_nonnegative_p (enum tree_code, tree, tree, int);
extern bool tree_binary_nonnegative_p (enum tree_code, tree, tree, tree, int);
extern bool tree_single_nonnegative_warnv_p (tree, bool *, int);
extern bool tree_call_nonnegative_warnv_p (tree, combined_fn, tree, tree,
switch (get_gimple_rhs_class (code))
{
case GIMPLE_UNARY_RHS:
- return tree_unary_nonnegative_warnv_p (gimple_assign_rhs_code (stmt),
- type,
- gimple_assign_rhs1 (stmt),
- strict_overflow_p, depth);
+ return tree_unary_nonnegative_p (gimple_assign_rhs_code (stmt),
+ type,
+ gimple_assign_rhs1 (stmt),
+ depth);
case GIMPLE_BINARY_RHS:
return tree_binary_nonnegative_p (gimple_assign_rhs_code (stmt),
type,
+++ /dev/null
-/* { dg-do compile } */
-/* { dg-options "-fstrict-overflow -O2" } */
-/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#pragma GCC diagnostic error "-Wstrict-overflow"
-
-int
-foo (int i)
-{
- return __builtin_abs (i) >= 0; /* { dg-error "assuming signed overflow does not occur" "correct warning" } */
-}
+++ /dev/null
-/* { dg-do compile } */
-/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2" } */
-
-/* Source: Ian Lance Taylor. */
-
-int
-foo (int i)
-{
- return __builtin_abs (i) >= 0; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */
-}