+2002-04-01 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * c-common.c (unsigned_conversion_warning, convert_and_check,
+ unsigned_type, signed_type, shorten_compare,
+ c_common_get_alias_set, c_common_nodes_and_builtins): Use new hooks.
+ (unsigned_type, signed_type, signed_or_unsigned_type): Rename.
+ * c-common.h (unsigned_type, signed_type, signed_or_unsigned_type):
+ New.
+ * c-decl.c (grokdeclarator): Update.
+ * c-format.c (check_format_types): Update.
+ * c-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
+ LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
+ * c-typeck.c (build_binary_op, convert_for_assignment): Update.
+ * convert.c (convert_to_integer): Use new hooks.
+ * expmed.c (make_tree): Use new hooks.
+ * expr.c (store_expr): Use new hooks.
+ * fold-const.c (operand_equal_for_comparison_p, build_range_check,
+ all_ones_mask_p, unextend, fold): Use new hooks.
+ * langhooks.h (struct lang_hooks_for_types): New hooks.
+ * tree.h (signed_or_unsigned_type, signed_type,
+ unsigned_type): Remove.
+objc:
+ * objc-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
+ LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
+
2002-03-31 Richard Henderson <rth@redhat.com>
* config/ia64/unwind-ia64.c (alloc_spill_area): Fix offset.
+2002-04-01 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * gigi.h (unsigned_type, signed_type, signed_or_unsigned_type):
+ Rename.
+ * misc.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
+ LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
+ * trans.c (tree_transform, convert_with_check): Update.
+ * utils.c (unsigned_type, signed_type, signed_or_unsigned_type):
+ Rename.
+
2002-03-31 Neil Booth <neil@daikokuya.demon.co.uk>
* gigi.h (finish_incomplete_decl): Rename.
extern tree gnat_type_for_mode PARAMS ((enum machine_mode, int));
/* Return the unsigned version of a TYPE_NODE, a scalar type. */
-extern tree unsigned_type PARAMS ((tree));
+extern tree gnat_unsigned_type PARAMS ((tree));
/* Return the signed version of a TYPE_NODE, a scalar type. */
-extern tree signed_type PARAMS ((tree));
+extern tree gnat_signed_type PARAMS ((tree));
/* Return a type the same as TYPE except unsigned or signed according to
UNSIGNEDP. */
-extern tree signed_or_unsigned_type PARAMS ((int, tree));
+extern tree gnat_signed_or_unsigned_type PARAMS ((int, tree));
/* This routine is called in tree.c to print an error message for invalid use
of an incomplete type. */
#define LANG_HOOKS_TYPE_FOR_MODE gnat_type_for_mode
#undef LANG_HOOKS_TYPE_FOR_SIZE
#define LANG_HOOKS_TYPE_FOR_SIZE gnat_type_for_size
+#undef LANG_HOOKS_SIGNED_TYPE
+#define LANG_HOOKS_SIGNED_TYPE gnat_signed_type
+#undef LANG_HOOKS_UNSIGNED_TYPE
+#define LANG_HOOKS_UNSIGNED_TYPE gnat_unsigned_type
+#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
+#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE gnat_signed_or_unsigned_type
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
/* 'Length or 'Range_Length. */
{
tree gnu_compute_type
- = signed_or_unsigned_type
+ = gnat_signed_or_unsigned_type
(0, get_base_type (gnu_result_type));
gnu_result
so we may need to choose a different type. */
if (Nkind (gnat_node) == N_Op_Shift_Right
&& ! TREE_UNSIGNED (gnu_type))
- gnu_type = unsigned_type (gnu_type);
+ gnu_type = gnat_unsigned_type (gnu_type);
else if (Nkind (gnat_node) == N_Op_Shift_Right_Arithmetic
&& TREE_UNSIGNED (gnu_type))
- gnu_type = signed_type (gnu_type);
+ gnu_type = gnat_signed_type (gnu_type);
if (gnu_type != gnu_result_type)
{
comparing them properly. Likewise, convert the upper bounds
to unsigned types. */
if (INTEGRAL_TYPE_P (gnu_in_basetype) && TREE_UNSIGNED (gnu_in_basetype))
- gnu_in_lb = convert (signed_type (gnu_in_basetype), gnu_in_lb);
+ gnu_in_lb = convert (gnat_signed_type (gnu_in_basetype), gnu_in_lb);
if (INTEGRAL_TYPE_P (gnu_in_basetype)
&& ! TREE_UNSIGNED (gnu_in_basetype))
- gnu_in_ub = convert (unsigned_type (gnu_in_basetype), gnu_in_ub);
+ gnu_in_ub = convert (gnat_unsigned_type (gnu_in_basetype), gnu_in_ub);
if (INTEGRAL_TYPE_P (gnu_base_type) && TREE_UNSIGNED (gnu_base_type))
- gnu_out_lb = convert (signed_type (gnu_base_type), gnu_out_lb);
+ gnu_out_lb = convert (gnat_signed_type (gnu_base_type), gnu_out_lb);
if (INTEGRAL_TYPE_P (gnu_base_type) && ! TREE_UNSIGNED (gnu_base_type))
- gnu_out_ub = convert (unsigned_type (gnu_base_type), gnu_out_ub);
+ gnu_out_ub = convert (gnat_unsigned_type (gnu_base_type), gnu_out_ub);
/* Check each bound separately and only if the result bound
is tighter than the bound on the input type. Note that all the
/* Return the unsigned version of a TYPE_NODE, a scalar type. */
tree
-unsigned_type (type_node)
+gnat_unsigned_type (type_node)
tree type_node;
{
tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 1);
/* Return the signed version of a TYPE_NODE, a scalar type. */
tree
-signed_type (type_node)
+gnat_signed_type (type_node)
tree type_node;
{
tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 0);
UNSIGNEDP. */
tree
-signed_or_unsigned_type (unsignedp, type)
+gnat_signed_or_unsigned_type (unsignedp, type)
int unsignedp;
tree type;
{
unsigned_conversion_warning (result, operand)
tree result, operand;
{
+ tree type = TREE_TYPE (result);
+
if (TREE_CODE (operand) == INTEGER_CST
- && TREE_CODE (TREE_TYPE (result)) == INTEGER_TYPE
- && TREE_UNSIGNED (TREE_TYPE (result))
+ && TREE_CODE (type) == INTEGER_TYPE
+ && TREE_UNSIGNED (type)
&& skip_evaluation == 0
- && !int_fits_type_p (operand, TREE_TYPE (result)))
+ && !int_fits_type_p (operand, type))
{
- if (!int_fits_type_p (operand, signed_type (TREE_TYPE (result))))
+ if (!int_fits_type_p (operand, c_common_signed_type (type)))
/* This detects cases like converting -129 or 256 to unsigned char. */
warning ("large integer implicitly truncated to unsigned type");
else if (warn_conversion)
don't warn unless pedantic. */
if ((pedantic
|| TREE_UNSIGNED (type)
- || ! constant_fits_type_p (expr, unsigned_type (type)))
+ || ! constant_fits_type_p (expr,
+ c_common_unsigned_type (type)))
&& skip_evaluation == 0)
warning ("overflow in implicit constant conversion");
}
/* Return an unsigned type the same as TYPE in other respects. */
tree
-unsigned_type (type)
+c_common_unsigned_type (type)
tree type;
{
tree type1 = TYPE_MAIN_VARIANT (type);
if (type1 == intQI_type_node)
return unsigned_intQI_type_node;
- return signed_or_unsigned_type (1, type);
+ return c_common_signed_or_unsigned_type (1, type);
}
/* Return a signed type the same as TYPE in other respects. */
tree
-signed_type (type)
+c_common_signed_type (type)
tree type;
{
tree type1 = TYPE_MAIN_VARIANT (type);
if (type1 == unsigned_intQI_type_node)
return intQI_type_node;
- return signed_or_unsigned_type (0, type);
+ return c_common_signed_or_unsigned_type (0, type);
}
/* Return a type the same as TYPE except unsigned or
signed according to UNSIGNEDP. */
tree
-signed_or_unsigned_type (unsignedp, type)
+c_common_signed_or_unsigned_type (unsignedp, type)
int unsignedp;
tree type;
{
int unsignedp = TREE_UNSIGNED (*restype_ptr);
tree val;
- type = signed_or_unsigned_type (unsignedp0, TREE_TYPE (primop0));
+ type = c_common_signed_or_unsigned_type (unsignedp0,
+ TREE_TYPE (primop0));
/* If TYPE is an enumeration, then we need to get its min/max
values from it's underlying integral type, not the enumerated
minval = TYPE_MIN_VALUE (type);
if (unsignedp && !unsignedp0)
- *restype_ptr = signed_type (*restype_ptr);
+ *restype_ptr = c_common_signed_type (*restype_ptr);
if (TREE_TYPE (primop1) != *restype_ptr)
primop1 = convert (*restype_ptr, primop1);
default:
break;
}
- type = unsigned_type (type);
+ type = c_common_unsigned_type (type);
}
if (!max_gt && !unsignedp0 && TREE_CODE (primop0) != INTEGER_CST)
&& TYPE_PRECISION (TREE_TYPE (primop1)) < TYPE_PRECISION (*restype_ptr))
{
type = common_type (TREE_TYPE (primop0), TREE_TYPE (primop1));
- type = signed_or_unsigned_type (unsignedp0
- || TREE_UNSIGNED (*restype_ptr),
- type);
+ type = c_common_signed_or_unsigned_type (unsignedp0
+ || TREE_UNSIGNED (*restype_ptr),
+ type);
/* Make sure shorter operand is extended the right way
to match the longer operand. */
- primop0 = convert (signed_or_unsigned_type (unsignedp0, TREE_TYPE (primop0)),
- primop0);
- primop1 = convert (signed_or_unsigned_type (unsignedp1, TREE_TYPE (primop1)),
- primop1);
+ primop0
+ = convert (c_common_signed_or_unsigned_type (unsignedp0,
+ TREE_TYPE (primop0)),
+ primop0);
+ primop1
+ = convert (c_common_signed_or_unsigned_type (unsignedp1,
+ TREE_TYPE (primop1)),
+ primop1);
}
else
{
so suppress the warning. */
if (extra_warnings && !in_system_header
&& ! (TREE_CODE (primop0) == INTEGER_CST
- && ! TREE_OVERFLOW (convert (signed_type (type),
+ && ! TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
warning ("comparison of unsigned expression >= 0 is always true");
value = boolean_true_node;
case LT_EXPR:
if (extra_warnings && !in_system_header
&& ! (TREE_CODE (primop0) == INTEGER_CST
- && ! TREE_OVERFLOW (convert (signed_type (type),
+ && ! TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
warning ("comparison of unsigned expression < 0 is always false");
value = boolean_false_node;
variant as canonical. */
if (TREE_CODE (t) == INTEGER_TYPE && TREE_UNSIGNED (t))
{
- tree t1 = signed_type (t);
+ tree t1 = c_common_signed_type (t);
/* t1 == t can happen for boolean nodes which are always unsigned. */
if (t1 != t)
and this must agree, even if long and int are the same size. */
c_size_type_node =
TREE_TYPE (identifier_global_value (get_identifier (SIZE_TYPE)));
- signed_size_type_node = signed_type (c_size_type_node);
+ signed_size_type_node = c_common_signed_type (c_size_type_node);
set_sizetype (c_size_type_node);
build_common_tree_nodes_2 (flag_short_double);
}
else
{
- signed_wchar_type_node = signed_type (wchar_type_node);
- unsigned_wchar_type_node = unsigned_type (wchar_type_node);
+ signed_wchar_type_node = c_common_signed_type (wchar_type_node);
+ unsigned_wchar_type_node = c_common_unsigned_type (wchar_type_node);
}
/* This is for wide string constants. */
default_function_type = build_function_type (integer_type_node, NULL_TREE);
ptrdiff_type_node
= TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE)));
- unsigned_ptrdiff_type_node = unsigned_type (ptrdiff_type_node);
+ unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
(*lang_hooks.decls.pushdecl)
(build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"),
extern tree c_common_type_for_mode PARAMS ((enum machine_mode,
int));
extern tree c_common_type_for_size PARAMS ((unsigned int, int));
+extern tree c_common_unsigned_type PARAMS ((tree));
+extern tree c_common_signed_type PARAMS ((tree));
+extern tree c_common_signed_or_unsigned_type PARAMS ((int, tree));
extern void c_apply_type_quals_to_decl PARAMS ((int, tree));
extern tree c_sizeof PARAMS ((tree));
extern tree c_alignof PARAMS ((tree));
else if (type == char_type_node)
type = unsigned_char_type_node;
else if (typedef_decl)
- type = unsigned_type (type);
+ type = c_common_unsigned_type (type);
else
type = unsigned_type_node;
}
tree itype = NULL_TREE;
tree size = TREE_OPERAND (declarator, 1);
/* The index is a signed object `sizetype' bits wide. */
- tree index_type = signed_type (sizetype);
+ tree index_type = c_common_signed_type (sizetype);
array_ptr_quals = TREE_TYPE (declarator);
array_parm_static = TREE_STATIC (declarator);
&& TREE_CODE (cur_type) == INTEGER_TYPE
&& (! pedantic || i == 0 || (i == 1 && char_type_flag))
&& (TREE_UNSIGNED (wanted_type)
- ? wanted_type == unsigned_type (cur_type)
- : wanted_type == signed_type (cur_type)))
+ ? wanted_type == c_common_unsigned_type (cur_type)
+ : wanted_type == c_common_signed_type (cur_type)))
continue;
/* Likewise, "signed char", "unsigned char" and "char" are
equivalent but the above test won't consider them equivalent. */
#define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode
#undef LANG_HOOKS_TYPE_FOR_SIZE
#define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
+#undef LANG_HOOKS_SIGNED_TYPE
+#define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
+#undef LANG_HOOKS_UNSIGNED_TYPE
+#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
+#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
+#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
/* ### When changing hooks, consider if ObjC needs changing too!! ### */
&& unsigned0 == unsigned1
&& (unsigned0 || !uns))
result_type
- = signed_or_unsigned_type (unsigned0,
- common_type (TREE_TYPE (arg0), TREE_TYPE (arg1)));
+ = c_common_signed_or_unsigned_type
+ (unsigned0, common_type (TREE_TYPE (arg0), TREE_TYPE (arg1)));
else if (TREE_CODE (arg0) == INTEGER_CST
&& (unsigned1 || !uns)
&& (TYPE_PRECISION (TREE_TYPE (arg1))
< TYPE_PRECISION (result_type))
- && (type = signed_or_unsigned_type (unsigned1,
- TREE_TYPE (arg1)),
+ && (type
+ = c_common_signed_or_unsigned_type (unsigned1,
+ TREE_TYPE (arg1)),
int_fits_type_p (arg0, type)))
result_type = type;
else if (TREE_CODE (arg1) == INTEGER_CST
&& (unsigned0 || !uns)
&& (TYPE_PRECISION (TREE_TYPE (arg0))
< TYPE_PRECISION (result_type))
- && (type = signed_or_unsigned_type (unsigned0,
- TREE_TYPE (arg0)),
+ && (type
+ = c_common_signed_or_unsigned_type (unsigned0,
+ TREE_TYPE (arg0)),
int_fits_type_p (arg1, type)))
result_type = type;
}
{
/* Do an unsigned shift if the operand was zero-extended. */
result_type
- = signed_or_unsigned_type (unsigned_arg, TREE_TYPE (arg0));
+ = c_common_signed_or_unsigned_type (unsigned_arg,
+ TREE_TYPE (arg0));
/* Convert value-to-be-shifted to that type. */
if (TREE_TYPE (op0) != result_type)
op0 = convert (result_type, op0);
would fit in the result if the result were signed. */
else if (TREE_CODE (uop) == INTEGER_CST
&& (resultcode == EQ_EXPR || resultcode == NE_EXPR)
- && int_fits_type_p (uop, signed_type (result_type)))
+ && int_fits_type_p
+ (uop, c_common_signed_type (result_type)))
/* OK */;
/* Do not warn if the unsigned quantity is an enumeration
constant and its maximum value would fit in the result
if the result were signed. */
else if (TREE_CODE (uop) == INTEGER_CST
&& TREE_CODE (TREE_TYPE (uop)) == ENUMERAL_TYPE
- && int_fits_type_p (TYPE_MAX_VALUE (TREE_TYPE(uop)),
- signed_type (result_type)))
+ && int_fits_type_p
+ (TYPE_MAX_VALUE (TREE_TYPE(uop)),
+ c_common_signed_type (result_type)))
/* OK */;
else
warning ("comparison between signed and unsigned");
Meanwhile, the lhs target must have all the qualifiers of the rhs. */
if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
|| comp_target_types (type, rhstype)
- || (unsigned_type (TYPE_MAIN_VARIANT (ttl))
- == unsigned_type (TYPE_MAIN_VARIANT (ttr))))
+ || (c_common_unsigned_type (TYPE_MAIN_VARIANT (ttl))
+ == c_common_unsigned_type (TYPE_MAIN_VARIANT (ttr))))
{
if (pedantic
&& ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
unsigned then can safely do the work as unsigned.
And we may need to do it as unsigned
if we truncate to the original size. */
- typex = ((TREE_UNSIGNED (TREE_TYPE (expr))
- || (TREE_UNSIGNED (TREE_TYPE (arg0))
- && TREE_UNSIGNED (TREE_TYPE (arg1))))
- ? unsigned_type (typex) : signed_type (typex));
+ if (TREE_UNSIGNED (TREE_TYPE (expr))
+ || (TREE_UNSIGNED (TREE_TYPE (arg0))
+ && TREE_UNSIGNED (TREE_TYPE (arg1))))
+ typex = (*lang_hooks.types.unsigned_type) (typex);
+ else
+ typex = (*lang_hooks.types.signed_type) (typex);
return convert (type,
fold (build (ex_form, typex,
convert (typex, arg0),
{
/* Don't do unsigned arithmetic where signed was wanted,
or vice versa. */
- typex = (TREE_UNSIGNED (TREE_TYPE (expr))
- ? unsigned_type (typex) : signed_type (typex));
+ if (TREE_UNSIGNED (TREE_TYPE (expr)))
+ typex = (*lang_hooks.types.unsigned_type) (typex);
+ else
+ typex = (*lang_hooks.types.signed_type) (typex);
return convert (type,
fold (build1 (ex_form, typex,
convert (typex,
+2002-04-01 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * cp-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
+ LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
+ * decl.c (grokdeclarator): Update.
+ * mangle.c (write_integer_cst): Update.
+ * typeck.c (build_binary_op): Update.
+
2002-03-31 Neil Booth <neil@daikokuya.demon.co.uk>
* cp-lang.c (LANG_HOOKS_UNSAFE_FOR_REEVAL): Redefine.
#define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode
#undef LANG_HOOKS_TYPE_FOR_SIZE
#define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
+#undef LANG_HOOKS_SIGNED_TYPE
+#define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
+#undef LANG_HOOKS_UNSIGNED_TYPE
+#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
+#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
+#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
/* Each front end provides its own hooks, for toplev.c. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
else if (type == char_type_node)
type = unsigned_char_type_node;
else if (typedef_decl)
- type = unsigned_type (type);
+ type = c_common_unsigned_type (type);
else
type = unsigned_type_node;
}
chunk *= chunk;
}
- type = signed_or_unsigned_type (1, TREE_TYPE (cst));
+ type = c_common_signed_or_unsigned_type (1, TREE_TYPE (cst));
base = build_int_2 (chunk, 0);
n = build_int_2 (TREE_INT_CST_LOW (cst), TREE_INT_CST_HIGH (cst));
TREE_TYPE (n) = TREE_TYPE (base) = type;
== TYPE_PRECISION (TREE_TYPE (arg0)))
&& unsigned0 == unsigned1
&& (unsigned0 || !uns))
- result_type
- = signed_or_unsigned_type (unsigned0,
- common_type (TREE_TYPE (arg0),
- TREE_TYPE (arg1)));
+ result_type = c_common_signed_or_unsigned_type
+ (unsigned0, common_type (TREE_TYPE (arg0), TREE_TYPE (arg1)));
else if (TREE_CODE (arg0) == INTEGER_CST
&& (unsigned1 || !uns)
&& (TYPE_PRECISION (TREE_TYPE (arg1))
< TYPE_PRECISION (result_type))
- && (type = signed_or_unsigned_type (unsigned1,
- TREE_TYPE (arg1)),
+ && (type = c_common_signed_or_unsigned_type
+ (unsigned1, TREE_TYPE (arg1)),
int_fits_type_p (arg0, type)))
result_type = type;
else if (TREE_CODE (arg1) == INTEGER_CST
&& (unsigned0 || !uns)
&& (TYPE_PRECISION (TREE_TYPE (arg0))
< TYPE_PRECISION (result_type))
- && (type = signed_or_unsigned_type (unsigned0,
- TREE_TYPE (arg0)),
+ && (type = c_common_signed_or_unsigned_type
+ (unsigned0, TREE_TYPE (arg0)),
int_fits_type_p (arg1, type)))
result_type = type;
}
{
/* Do an unsigned shift if the operand was zero-extended. */
result_type
- = signed_or_unsigned_type (unsigned_arg,
- TREE_TYPE (arg0));
+ = c_common_signed_or_unsigned_type (unsigned_arg,
+ TREE_TYPE (arg0));
/* Convert value-to-be-shifted to that type. */
if (TREE_TYPE (op0) != result_type)
op0 = cp_convert (result_type, op0);
not use the most significant bit of result_type. */
else if ((resultcode == EQ_EXPR || resultcode == NE_EXPR)
&& ((op0_signed && TREE_CODE (orig_op1) == INTEGER_CST
- && int_fits_type_p (orig_op1,
- signed_type (result_type)))
+ && int_fits_type_p (orig_op1, c_common_signed_type
+ (result_type)))
|| (op1_signed && TREE_CODE (orig_op0) == INTEGER_CST
- && int_fits_type_p (orig_op0,
- signed_type (result_type)))))
+ && int_fits_type_p (orig_op0, c_common_signed_type
+ (result_type)))))
/* OK */;
else
warning ("comparison between signed and unsigned integer expressions");
make_tree (type, XEXP (x, 1))));
case LSHIFTRT:
+ t = (*lang_hooks.types.unsigned_type) (type);
return fold (convert (type,
- build (RSHIFT_EXPR, unsigned_type (type),
- make_tree (unsigned_type (type),
- XEXP (x, 0)),
+ build (RSHIFT_EXPR, t,
+ make_tree (t, XEXP (x, 0)),
make_tree (type, XEXP (x, 1)))));
case ASHIFTRT:
+ t = (*lang_hooks.types.signed_type) (type);
return fold (convert (type,
- build (RSHIFT_EXPR, signed_type (type),
- make_tree (signed_type (type), XEXP (x, 0)),
+ build (RSHIFT_EXPR, t,
+ make_tree (t, XEXP (x, 0)),
make_tree (type, XEXP (x, 1)))));
case DIV:
if (TREE_CODE (type) != REAL_TYPE)
- t = signed_type (type);
+ t = (*lang_hooks.types.signed_type) (type);
else
t = type;
make_tree (t, XEXP (x, 0)),
make_tree (t, XEXP (x, 1)))));
case UDIV:
- t = unsigned_type (type);
+ t = (*lang_hooks.types.unsigned_type) (type);
return fold (convert (type,
build (TRUNC_DIV_EXPR, t,
make_tree (t, XEXP (x, 0)),
{
if (TREE_UNSIGNED (TREE_TYPE (exp))
!= SUBREG_PROMOTED_UNSIGNED_P (target))
- exp
- = convert
- (signed_or_unsigned_type (SUBREG_PROMOTED_UNSIGNED_P (target),
- TREE_TYPE (exp)),
- exp);
+ exp = convert
+ ((*lang_hooks.types.signed_or_unsigned_type)
+ (SUBREG_PROMOTED_UNSIGNED_P (target), TREE_TYPE (exp)), exp);
exp = convert ((*lang_hooks.types.type_for_mode)
(GET_MODE (SUBREG_REG (target)),
+Mon Apr 1 09:59:53 2002 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * com.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
+ LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
+ (unsigned_type, signed_type, signed_or_unsigned_type): Rename.
+
Sun Mar 31 23:50:22 2002 Neil Booth <neil@daikokuya.demon.co.uk>
* com.c (lang_print_error_function): Rename.
static tree ffe_type_for_mode PARAMS ((enum machine_mode, int));
static tree ffe_type_for_size PARAMS ((unsigned int, int));
+static tree ffe_unsigned_type PARAMS ((tree));
+static tree ffe_signed_type PARAMS ((tree));
+static tree ffe_signed_or_unsigned_type PARAMS ((int, tree));
static void ffecom_init_decl_processing PARAMS ((void));
static tree ffecom_arglist_expr_ (const char *argstring, ffebld args);
static tree ffecom_widest_expr_type_ (ffebld list);
#define LANG_HOOKS_DECL_PRINTABLE_NAME ffe_printable_name
#undef LANG_HOOKS_PRINT_ERROR_FUNCTION
#define LANG_HOOKS_PRINT_ERROR_FUNCTION ffe_print_error_function
+
#undef LANG_HOOKS_TYPE_FOR_MODE
#define LANG_HOOKS_TYPE_FOR_MODE ffe_type_for_mode
#undef LANG_HOOKS_TYPE_FOR_SIZE
#define LANG_HOOKS_TYPE_FOR_SIZE ffe_type_for_size
+#undef LANG_HOOKS_SIGNED_TYPE
+#define LANG_HOOKS_SIGNED_TYPE ffe_signed_type
+#undef LANG_HOOKS_UNSIGNED_TYPE
+#define LANG_HOOKS_UNSIGNED_TYPE ffe_unsigned_type
+#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
+#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE ffe_signed_or_unsigned_type
/* We do not wish to use alias-set based aliasing at all. Used in the
extreme (every object with its own set, with equivalences recorded) it
BLOCK_SUBBLOCKS (block));
}
-tree
-signed_or_unsigned_type (unsignedp, type)
+static tree
+ffe_signed_or_unsigned_type (unsignedp, type)
int unsignedp;
tree type;
{
return type2;
}
-tree
-signed_type (type)
+static tree
+ffe_signed_type (type)
tree type;
{
tree type1 = TYPE_MAIN_VARIANT (type);
return 0;
}
-tree
-unsigned_type (type)
+static tree
+ffe_unsigned_type (type)
tree type;
{
tree type1 = TYPE_MAIN_VARIANT (type);
/* Make sure shorter operand is extended the right way
to match the longer operand. */
- primarg1 = convert (signed_or_unsigned_type (unsignedp1,
- TREE_TYPE (primarg1)),
- primarg1);
+ primarg1 = convert ((*lang_hooks.types.signed_or_unsigned_type)
+ (unsignedp1, TREE_TYPE (primarg1)), primarg1);
if (operand_equal_p (arg0, convert (type, primarg1), 0))
return 1;
tree tmask;
tmask = build_int_2 (~0, ~0);
- TREE_TYPE (tmask) = signed_type (type);
+ TREE_TYPE (tmask) = (*lang_hooks.types.signed_type) (type);
force_fit_type (tmask, 0);
return
tree_int_cst_equal (mask,
else if (integer_zerop (low))
{
- utype = unsigned_type (etype);
+ utype = (*lang_hooks.types.unsigned_type) (etype);
return build_range_check (type, convert (utype, exp), 1, 0,
convert (utype, high));
}
zero or one, and the conversion to a signed type can never overflow.
We could get an overflow if this conversion is done anywhere else. */
if (TREE_UNSIGNED (type))
- temp = convert (signed_type (type), temp);
+ temp = convert ((*lang_hooks.types.signed_type) (type), temp);
temp = const_binop (LSHIFT_EXPR, temp, size_int (modesize - 1), 0);
temp = const_binop (RSHIFT_EXPR, temp, size_int (modesize - p - 1), 0);
|| TREE_CODE (arg0) == ROUND_MOD_EXPR)
&& integer_pow2p (TREE_OPERAND (arg0, 1)))
{
- tree newtype = unsigned_type (TREE_TYPE (arg0));
+ tree newtype = (*lang_hooks.types.unsigned_type) (TREE_TYPE (arg0));
tree newmod = build (TREE_CODE (arg0), newtype,
convert (newtype, TREE_OPERAND (arg0, 0)),
convert (newtype, TREE_OPERAND (arg0, 1)));
&& TREE_UNSIGNED (TREE_TYPE (arg1))
/* signed_type does not work on pointer types. */
&& INTEGRAL_TYPE_P (TREE_TYPE (arg1)))
- switch (TREE_CODE (t))
- {
- case LE_EXPR:
- return fold (build (GE_EXPR, type,
- convert (signed_type (TREE_TYPE (arg0)),
- arg0),
- convert (signed_type (TREE_TYPE (arg1)),
- integer_zero_node)));
- case GT_EXPR:
- return fold (build (LT_EXPR, type,
- convert (signed_type (TREE_TYPE (arg0)),
- arg0),
- convert (signed_type (TREE_TYPE (arg1)),
- integer_zero_node)));
-
- default:
- break;
- }
-
+ {
+ if (TREE_CODE (t) == LE_EXPR || TREE_CODE (t) == GT_EXPR)
+ {
+ tree st0, st1;
+ st0 = (*lang_hooks.types.signed_type) (TREE_TYPE (arg0));
+ st1 = (*lang_hooks.types.signed_type) (TREE_TYPE (arg1));
+ return fold
+ (build (TREE_CODE (t) == LE_EXPR ? GE_EXPR: LT_EXPR,
+ type, convert (st0, arg0),
+ convert (st1, integer_zero_node)));
+ }
+ }
else if (TREE_INT_CST_HIGH (arg1) == 0
&& (TREE_INT_CST_LOW (arg1)
== ((unsigned HOST_WIDE_INT) 2 << (width - 1)) - 1)
case GE_EXPR:
case GT_EXPR:
if (TREE_UNSIGNED (TREE_TYPE (arg1)))
- arg1 = convert (signed_type (TREE_TYPE (arg1)), arg1);
+ arg1 = convert ((*lang_hooks.types.signed_type)
+ (TREE_TYPE (arg1)), arg1);
return pedantic_non_lvalue
(convert (type, fold (build1 (ABS_EXPR,
TREE_TYPE (arg1), arg1))));
case LE_EXPR:
case LT_EXPR:
if (TREE_UNSIGNED (TREE_TYPE (arg1)))
- arg1 = convert (signed_type (TREE_TYPE (arg1)), arg1);
+ arg1 = convert ((lang_hooks.types.signed_type)
+ (TREE_TYPE (arg1)), arg1);
return pedantic_non_lvalue
(negate_expr (convert (type,
fold (build1 (ABS_EXPR,
+2002-04-01 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * expr.c (build_java_binop): Update.
+ * java-tree.h (java_signed_type, java_unsigned_type,
+ java_signed_or_unsigned_type): Update.
+ * lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
+ LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
+ * parse.y (patch_binop): Update.
+ * typeck.c (signed_or_unsigned_type, unsigned_type,
+ signed_type): Update.
+
2002-03-31 Neil Booth <neil@daikokuya.demon.co.uk>
* lang.c (LANG_HOOKS_PRINT_ERROR_FUNCTION): Redefine.
{
case URSHIFT_EXPR:
{
- tree u_type = unsigned_type (type);
+ tree u_type = java_unsigned_type (type);
arg1 = convert (u_type, arg1);
arg1 = build_java_binop (RSHIFT_EXPR, u_type, arg1, arg2);
return convert (type, arg1);
extern void java_mark_tree PARAMS ((tree));
extern tree java_type_for_mode PARAMS ((enum machine_mode, int));
extern tree java_type_for_size PARAMS ((unsigned int, int));
+extern tree java_unsigned_type PARAMS ((tree));
+extern tree java_signed_type PARAMS ((tree));
+extern tree java_signed_or_unsigned_type PARAMS ((int, tree));
extern void add_assume_compiled PARAMS ((const char *, int));
extern tree lookup_class PARAMS ((tree));
extern tree lookup_java_constructor PARAMS ((tree, tree));
#define LANG_HOOKS_DECL_PRINTABLE_NAME lang_printable_name
#undef LANG_HOOKS_PRINT_ERROR_FUNCTION
#define LANG_HOOKS_PRINT_ERROR_FUNCTION java_print_error_function
+
#undef LANG_HOOKS_TYPE_FOR_MODE
#define LANG_HOOKS_TYPE_FOR_MODE java_type_for_mode
#undef LANG_HOOKS_TYPE_FOR_SIZE
#define LANG_HOOKS_TYPE_FOR_SIZE java_type_for_size
+#undef LANG_HOOKS_SIGNED_TYPE
+#define LANG_HOOKS_SIGNED_TYPE java_signed_type
+#undef LANG_HOOKS_UNSIGNED_TYPE
+#define LANG_HOOKS_UNSIGNED_TYPE java_unsigned_type
+#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
+#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE java_signed_or_unsigned_type
/* Each front end provides its own. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
if (code == URSHIFT_EXPR && ! flag_emit_class_files)
{
tree to_return;
- tree utype = unsigned_type (prom_type);
+ tree utype = java_unsigned_type (prom_type);
op1 = convert (utype, op1);
TREE_SET_CODE (node, RSHIFT_EXPR);
TREE_OPERAND (node, 0) = op1;
signed according to UNSIGNEDP. */
tree
-signed_or_unsigned_type (unsignedp, type)
+java_signed_or_unsigned_type (unsignedp, type)
int unsignedp;
tree type;
{
/* Return a signed type the same as TYPE in other respects. */
tree
-signed_type (type)
+java_signed_type (type)
tree type;
{
- return signed_or_unsigned_type (0, type);
+ return java_signed_or_unsigned_type (0, type);
}
/* Return an unsigned type the same as TYPE in other respects. */
tree
-unsigned_type (type)
+java_unsigned_type (type)
tree type;
{
- return signed_or_unsigned_type (1, type);
-
+ return java_signed_or_unsigned_type (1, type);
}
/* Mark EXP saying that we need to be able to take the
#define LANG_HOOKS_FOR_TYPES_INITIALIZER { \
LANG_HOOKS_MAKE_TYPE, \
LANG_HOOKS_TYPE_FOR_MODE, \
- LANG_HOOKS_TYPE_FOR_SIZE \
+ LANG_HOOKS_TYPE_FOR_SIZE, \
+ LANG_HOOKS_UNSIGNED_TYPE, \
+ LANG_HOOKS_SIGNED_TYPE, \
+ LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE \
}
/* Declaration hooks. */
/* Given PRECISION and UNSIGNEDP, return a suitable type-tree for an
integer type with at least that precision. */
tree (*type_for_size) PARAMS ((unsigned, int));
+
+ /* Given an integer type T, return a type like T but unsigned.
+ If T is unsigned, the value is T. */
+ tree (*unsigned_type) PARAMS ((tree));
+
+ /* Given an integer type T, return a type like T but signed.
+ If T is signed, the value is T. */
+ tree (*signed_type) PARAMS ((tree));
+
+ /* Return a type the same as TYPE except unsigned or signed
+ according to UNSIGNEDP. */
+ tree (*signed_or_unsigned_type) PARAMS ((int, tree));
};
/* Language hooks related to decls and the symbol table. */
#define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode
#undef LANG_HOOKS_TYPE_FOR_SIZE
#define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
+#undef LANG_HOOKS_SIGNED_TYPE
+#define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
+#undef LANG_HOOKS_UNSIGNED_TYPE
+#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
+#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
+#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
/* Each front end provides its own hooks, for toplev.c. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
extern tree make_unsigned_type PARAMS ((int));
extern void initialize_sizetypes PARAMS ((void));
extern void set_sizetype PARAMS ((tree));
-extern tree signed_or_unsigned_type PARAMS ((int, tree));
extern void fixup_unsigned_type PARAMS ((tree));
extern tree build_pointer_type PARAMS ((tree));
extern tree build_reference_type PARAMS ((tree));
extern tree get_narrower PARAMS ((tree, int *));
-/* Given an integer type T, return a type like T but unsigned.
- If T is unsigned, the value is T.
- The definition of this resides in language-specific code
- as the repertoire of available types may vary. */
-
-extern tree unsigned_type PARAMS ((tree));
-
-/* Given an integer type T, return a type like T but signed.
- If T is signed, the value is T.
- The definition of this resides in language-specific code
- as the repertoire of available types may vary. */
-
-extern tree signed_type PARAMS ((tree));
-
/* Given an expression EXP that may be a COMPONENT_REF or an ARRAY_REF,
look for nested component-refs or array-refs at constant positions
and find the ultimate containing object, which is returned. */