/* Language-independent node constructors for parse phase of GNU compiler.
- Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc.
+ Copyright (C) 1987, 1988, 1992, 1993 Free Software Foundation, Inc.
This file is part of GNU CC.
tree i;
{
REAL_VALUE_TYPE d;
+ REAL_VALUE_TYPE e;
+ /* Some 386 compilers mishandle unsigned int to float conversions,
+ so introduce a temporary variable E to avoid those bugs. */
+
#ifdef REAL_ARITHMETIC
if (! TREE_UNSIGNED (TREE_TYPE (i)))
REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i));
if (TREE_INT_CST_HIGH (i) < 0 && ! TREE_UNSIGNED (TREE_TYPE (i)))
{
d = (double) (~ TREE_INT_CST_HIGH (i));
- d *= ((double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2))
+ e = ((double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2))
* (double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2)));
- d += (double) (unsigned HOST_WIDE_INT) (~ TREE_INT_CST_LOW (i));
+ d *= e;
+ e = (double) (unsigned HOST_WIDE_INT) (~ TREE_INT_CST_LOW (i));
+ d += e;
d = (- d - 1.0);
}
else
{
d = (double) (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (i);
- d *= ((double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2))
+ e = ((double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2))
* (double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2)));
- d += (double) (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (i);
+ d *= e;
+ e = (double) (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (i);
+ d += e;
}
#endif /* not REAL_ARITHMETIC */
return d;
size = TREE_INT_CST_LOW (TYPE_SIZE (type));
return (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
}
-
-/* Return, as an INTEGER_CST node, the number of elements for
- TYPE (which is an ARRAY_TYPE) minus one.
- This counts only elements of the top array. */
+\f
+/* Return, as a tree node, the number of elements for TYPE (which is an
+ ARRAY_TYPE) minus one. This counts only elements of the top array. */
tree
array_type_nelts (type)
tree type;
{
tree index_type = TYPE_DOMAIN (type);
- return (tree_int_cst_equal (TYPE_MIN_VALUE (index_type), integer_zero_node)
+
+ return (integer_zerop (TYPE_MIN_VALUE (index_type))
? TYPE_MAX_VALUE (index_type)
- : fold (build (MINUS_EXPR, integer_type_node,
+ : fold (build (MINUS_EXPR, TREE_TYPE (TYPE_MAX_VALUE (index_type)),
TYPE_MAX_VALUE (index_type),
TYPE_MIN_VALUE (index_type))));
}
if (index_type == 0)
{
- /* The main variant of an array type should always
- be an array whose element type is the main variant. */
- if (elt_type != TYPE_MAIN_VARIANT (elt_type))
- change_main_variant (t, build_array_type (TYPE_MAIN_VARIANT (elt_type),
- index_type));
-
return t;
}
hashcode = TYPE_HASH (elt_type) + TYPE_HASH (index_type);
t = type_hash_canon (hashcode, t);
+#if 0 /* This led to crashes, because it could put a temporary node
+ on the TYPE_NEXT_VARIANT chain of a permanent one. */
/* The main variant of an array type should always
be an array whose element type is the main variant. */
if (elt_type != TYPE_MAIN_VARIANT (elt_type))
change_main_variant (t, build_array_type (TYPE_MAIN_VARIANT (elt_type),
index_type));
+#endif
if (TYPE_SIZE (t) == 0)
layout_type (t);
register tree t;
int hashcode;
- if (TREE_CODE (value_type) == FUNCTION_TYPE
- || TREE_CODE (value_type) == ARRAY_TYPE)
+ if (TREE_CODE (value_type) == FUNCTION_TYPE)
{
- error ("function return type cannot be function or array");
+ error ("function return type cannot be function");
value_type = integer_type_node;
}
break;
first = 0;
}
- /* A change in nominal type can always be stripped. */
+ else /* bitschange == 0 */
+ {
+ /* A change in nominal type can always be stripped, but we must
+ preserve the unsignedness. */
+ if (first)
+ uns = TREE_UNSIGNED (TREE_TYPE (op));
+ first = 0;
+ }
win = op;
}
}
/* Return the innermost context enclosing DECL that is
- a RECORD_TYPE or UNION_TYPE, or zero if none.
+ a RECORD_TYPE, UNION_TYPE or QUAL_UNION_TYPE, or zero if none.
TYPE_DECLs and FUNCTION_DECLs are transparent to this function. */
tree
while (context)
{
if (TREE_CODE (context) == RECORD_TYPE
- || TREE_CODE (context) == UNION_TYPE)
+ || TREE_CODE (context) == UNION_TYPE
+ || TREE_CODE (context) == QUAL_UNION_TYPE)
return context;
if (TREE_CODE (context) == TYPE_DECL
|| TREE_CODE (context) == FUNCTION_DECL)