tree.c (get_unwidened): Use host_integerp and tree_low_cst.
* tree.c (get_unwidened): Use host_integerp and tree_low_cst. (int_fits_type_p): For variable bounds, call force_fit_type. From-SVN: r37460
This commit is contained in:
parent
bd7cf17efd
commit
3401c26b5c
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Nov 14 12:34:56 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
|
||||||
|
|
||||||
|
* tree.c (get_unwidened): Use host_integerp and tree_low_cst.
|
||||||
|
(int_fits_type_p): For variable bounds, call force_fit_type.
|
||||||
|
|
||||||
2000-11-14 Jakub Jelinek <jakub@redhat.com>
|
2000-11-14 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
* varasm.c (struct deferred_string): New structure.
|
* varasm.c (struct deferred_string): New structure.
|
||||||
|
|
44
gcc/tree.c
44
gcc/tree.c
|
@ -4210,10 +4210,11 @@ get_unwidened (op, for_type)
|
||||||
/* Since type_for_size always gives an integer type. */
|
/* Since type_for_size always gives an integer type. */
|
||||||
&& TREE_CODE (type) != REAL_TYPE
|
&& TREE_CODE (type) != REAL_TYPE
|
||||||
/* Don't crash if field not laid out yet. */
|
/* Don't crash if field not laid out yet. */
|
||||||
&& DECL_SIZE (TREE_OPERAND (op, 1)) != 0)
|
&& DECL_SIZE (TREE_OPERAND (op, 1)) != 0
|
||||||
|
&& host_integerp (DECL_SIZE (TREE_OPERAND (op, 1)), 1))
|
||||||
{
|
{
|
||||||
unsigned int innerprec
|
unsigned int innerprec
|
||||||
= TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (op, 1)));
|
= tree_low_cst (DECL_SIZE (TREE_OPERAND (op, 1)), 1);
|
||||||
|
|
||||||
type = type_for_size (innerprec, TREE_UNSIGNED (TREE_OPERAND (op, 1)));
|
type = type_for_size (innerprec, TREE_UNSIGNED (TREE_OPERAND (op, 1)));
|
||||||
|
|
||||||
|
@ -4235,6 +4236,7 @@ get_unwidened (op, for_type)
|
||||||
TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op);
|
TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4333,22 +4335,30 @@ int
|
||||||
int_fits_type_p (c, type)
|
int_fits_type_p (c, type)
|
||||||
tree c, type;
|
tree c, type;
|
||||||
{
|
{
|
||||||
if (TREE_UNSIGNED (type))
|
/* If the bounds of the type are integers, we can check ourselves.
|
||||||
return (! (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
|
Otherwise,. use force_fit_type, which checks against the precision. */
|
||||||
&& INT_CST_LT_UNSIGNED (TYPE_MAX_VALUE (type), c))
|
if (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
|
||||||
&& ! (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
|
&& TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
|
||||||
&& INT_CST_LT_UNSIGNED (c, TYPE_MIN_VALUE (type)))
|
{
|
||||||
/* Negative ints never fit unsigned types. */
|
if (TREE_UNSIGNED (type))
|
||||||
&& ! (TREE_INT_CST_HIGH (c) < 0
|
return (! INT_CST_LT_UNSIGNED (TYPE_MAX_VALUE (type), c)
|
||||||
&& ! TREE_UNSIGNED (TREE_TYPE (c))));
|
&& ! INT_CST_LT_UNSIGNED (c, TYPE_MIN_VALUE (type))
|
||||||
|
/* Negative ints never fit unsigned types. */
|
||||||
|
&& ! (TREE_INT_CST_HIGH (c) < 0
|
||||||
|
&& ! TREE_UNSIGNED (TREE_TYPE (c))));
|
||||||
|
else
|
||||||
|
return (! INT_CST_LT (TYPE_MAX_VALUE (type), c)
|
||||||
|
&& ! INT_CST_LT (c, TYPE_MIN_VALUE (type))
|
||||||
|
/* Unsigned ints with top bit set never fit signed types. */
|
||||||
|
&& ! (TREE_INT_CST_HIGH (c) < 0
|
||||||
|
&& TREE_UNSIGNED (TREE_TYPE (c))));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return (! (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
|
{
|
||||||
&& INT_CST_LT (TYPE_MAX_VALUE (type), c))
|
c = copy_node (c);
|
||||||
&& ! (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
|
TREE_TYPE (c) = type;
|
||||||
&& INT_CST_LT (c, TYPE_MIN_VALUE (type)))
|
return !force_fit_type (c, 0);
|
||||||
/* Unsigned ints with top bit set never fit signed types. */
|
}
|
||||||
&& ! (TREE_INT_CST_HIGH (c) < 0
|
|
||||||
&& TREE_UNSIGNED (TREE_TYPE (c))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Given a DECL or TYPE, return the scope in which it was declared, or
|
/* Given a DECL or TYPE, return the scope in which it was declared, or
|
||||||
|
|
Loading…
Reference in New Issue