#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_ATTRIBUTE_TABLE
#define LANG_HOOKS_ATTRIBUTE_TABLE gnat_internal_attribute_table
#undef LANG_HOOKS_BUILTIN_FUNCTION
}
gnu_compute_type
- = get_signed_or_unsigned_type (0,
+ = signed_or_unsigned_type_for (0,
get_base_type (gnu_result_type));
gnu_result
else
conversion_warning (type, expr);
}
- else if (!int_fits_type_p (expr, unsigned_type_for (type)))
+ else if (!int_fits_type_p (expr, c_common_unsigned_type (type)))
warning (OPT_Woverflow,
"overflow in implicit constant conversion");
/* No warning for converting 0x80000000 to int. */
return 0;
}
+tree
+c_common_unsigned_type (tree type)
+{
+ return c_common_signed_or_unsigned_type (1, type);
+}
+
/* Return a signed type the same as TYPE in other respects. */
tree
c_common_signed_type (tree type)
{
- tree type1 = TYPE_MAIN_VARIANT (type);
- if (type1 == unsigned_char_type_node || type1 == char_type_node)
- return signed_char_type_node;
- if (type1 == unsigned_type_node)
- return integer_type_node;
- if (type1 == short_unsigned_type_node)
- return short_integer_type_node;
- if (type1 == long_unsigned_type_node)
- return long_integer_type_node;
- if (type1 == long_long_unsigned_type_node)
- return long_long_integer_type_node;
- if (type1 == widest_unsigned_literal_type_node)
- return widest_integer_literal_type_node;
-#if HOST_BITS_PER_WIDE_INT >= 64
- if (type1 == unsigned_intTI_type_node)
- return intTI_type_node;
-#endif
- if (type1 == unsigned_intDI_type_node)
- return intDI_type_node;
- if (type1 == unsigned_intSI_type_node)
- return intSI_type_node;
- if (type1 == unsigned_intHI_type_node)
- return intHI_type_node;
- if (type1 == unsigned_intQI_type_node)
- return intQI_type_node;
-
return c_common_signed_or_unsigned_type (0, type);
}
default:
break;
}
- /* unsigned_type_for doesn't support C bit fields */
- type = c_common_signed_or_unsigned_type (1, type);
+ type = c_common_unsigned_type (type);
}
if (TREE_CODE (primop0) != INTEGER_CST)
else
{
signed_wchar_type_node = c_common_signed_type (wchar_type_node);
- unsigned_wchar_type_node = unsigned_type_for (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_for (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"),
/* Equality works here because c_common_signed_type uses
TYPE_MAIN_VARIANT. */
- return lang_hooks.types.signed_type (t1)
- == lang_hooks.types.signed_type (t2);
+ return c_common_signed_type (t1)
+ == c_common_signed_type (t2);
}
/* Check for missing format attributes on function pointers. LTYPE is
extern bool c_common_missing_argument (const char *opt, size_t code);
extern tree c_common_type_for_mode (enum machine_mode, int);
extern tree c_common_type_for_size (unsigned int, int);
+extern tree c_common_unsigned_type (tree);
extern tree c_common_signed_type (tree);
extern tree c_common_signed_or_unsigned_type (int, tree);
extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int);
"signed". */
if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
&& TREE_CODE (type) == INTEGER_TYPE)
- type = unsigned_type_for (type);
+ type = c_common_unsigned_type (type);
/* Figure out the type qualifiers for the declaration. There are
two ways a declaration can become qualified. One is something
&& TREE_CODE (cur_type) == INTEGER_TYPE
&& (!pedantic || i == 0 || (i == 1 && char_type_flag))
&& (TYPE_UNSIGNED (wanted_type)
- ? wanted_type == unsigned_type_for (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
#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_SIGNED_OR_UNSIGNED_TYPE
-#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
#undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR c_incomplete_type_error
#undef LANG_HOOKS_TYPE_PROMOTES_TO
if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
|| (target_cmp = comp_target_types (type, rhstype))
|| is_opaque_pointer
- || (unsigned_type_for (mvl)
- == unsigned_type_for (mvr)))
+ || (c_common_unsigned_type (mvl)
+ == c_common_unsigned_type (mvr)))
{
if (pedantic
&& ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
|| ex_form == MINUS_EXPR)))
typex = unsigned_type_for (typex);
else
- typex = lang_hooks.types.signed_type (typex);
+ typex = signed_type_for (typex);
return convert (type,
fold_build2 (ex_form, typex,
convert (typex, arg0),
if (TYPE_UNSIGNED (TREE_TYPE (expr)))
typex = unsigned_type_for (type);
else
- typex = lang_hooks.types.signed_type (type);
+ typex = signed_type_for (type);
return convert (type,
fold_build1 (ex_form, typex,
convert (typex,
#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_SIGNED_OR_UNSIGNED_TYPE
-#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
#undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error
#undef LANG_HOOKS_TYPE_PROMOTES_TO
make_tree (type, XEXP (x, 1))));
case ASHIFTRT:
- t = lang_hooks.types.signed_type (type);
+ t = signed_type_for (type);
return fold_convert (type, build2 (RSHIFT_EXPR, t,
make_tree (t, XEXP (x, 0)),
make_tree (type, XEXP (x, 1))));
case DIV:
if (TREE_CODE (type) != REAL_TYPE)
- t = lang_hooks.types.signed_type (type);
+ t = signed_type_for (type);
else
t = type;
/* Some types, e.g. Fortran's logical*4, won't have a signed
version, so use the mode instead. */
tree ntype
- = (get_signed_or_unsigned_type
+ = (signed_or_unsigned_type_for
(SUBREG_PROMOTED_UNSIGNED_P (target), TREE_TYPE (exp)));
if (ntype == NULL)
ntype = lang_hooks.types.type_for_mode
== TREE_INT_CST_LOW (op1))
{
tree ntype = TYPE_UNSIGNED (type)
- ? lang_hooks.types.signed_type (type)
+ ? signed_type_for (type)
: unsigned_type_for (type);
tree temp = fold_convert (ntype, TREE_OPERAND (t, 0));
temp = fold_build2 (RSHIFT_EXPR, ntype, temp, op1);
else if (type == bitsizetype)
ctype = sbitsizetype;
else
- ctype = lang_hooks.types.signed_type (type);
+ ctype = signed_type_for (type);
/* If either operand is not a constant, do the conversions to the signed
type and subtract. The hardware will do the right thing with any
/* Make sure shorter operand is extended the right way
to match the longer operand. */
- primarg1 = fold_convert (get_signed_or_unsigned_type
+ primarg1 = fold_convert (signed_or_unsigned_type_for
(unsignedp1, TREE_TYPE (primarg1)), primarg1);
if (operand_equal_p (arg0, fold_convert (type, primarg1), 0))
unsigned int precision = TYPE_PRECISION (type);
tree tmask;
- tmask = build_int_cst_type (lang_hooks.types.signed_type (type), -1);
+ tmask = build_int_cst_type (signed_type_for (type), -1);
return
tree_int_cst_equal (mask,
{
if (TYPE_UNSIGNED (etype))
{
- etype = lang_hooks.types.signed_type (etype);
+ etype = signed_type_for (etype);
exp = fold_convert (etype, exp);
}
return fold_build2 (GT_EXPR, type, exp,
case GE_EXPR:
case GT_EXPR:
if (TYPE_UNSIGNED (TREE_TYPE (arg1)))
- arg1 = fold_convert (lang_hooks.types.signed_type
+ arg1 = fold_convert (signed_type_for
(TREE_TYPE (arg1)), arg1);
tem = fold_build1 (ABS_EXPR, TREE_TYPE (arg1), arg1);
return pedantic_non_lvalue (fold_convert (type, tem));
case LE_EXPR:
case LT_EXPR:
if (TYPE_UNSIGNED (TREE_TYPE (arg1)))
- arg1 = fold_convert (lang_hooks.types.signed_type
+ arg1 = fold_convert (signed_type_for
(TREE_TYPE (arg1)), arg1);
tem = fold_build1 (ABS_EXPR, TREE_TYPE (arg1), arg1);
return negate_expr (fold_convert (type, tem));
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 (TYPE_UNSIGNED (type))
- temp = fold_convert (lang_hooks.types.signed_type (type), temp);
+ temp = fold_convert (signed_type_for (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);
must avoid building ABS_EXPR itself as unsigned. */
if (TYPE_UNSIGNED (ctype) && !TYPE_UNSIGNED (type))
{
- tree cstype = (*lang_hooks.types.signed_type) (ctype);
+ tree cstype = (*signed_type_for) (ctype);
if ((t1 = extract_muldiv (op0, c, code, cstype, strict_overflow_p))
!= 0)
{
&& TYPE_PRECISION (TREE_TYPE (arg00))
== GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (arg00))))
{
- tree stype = lang_hooks.types.signed_type (TREE_TYPE (arg00));
+ tree stype = signed_type_for (TREE_TYPE (arg00));
return fold_build2 (code == EQ_EXPR ? GE_EXPR : LT_EXPR,
result_type, fold_convert (stype, arg00),
build_int_cst (stype, 0));
{
if (TYPE_UNSIGNED (itype))
{
- itype = lang_hooks.types.signed_type (itype);
+ itype = signed_type_for (itype);
arg00 = fold_convert (itype, arg00);
}
return fold_build2 (code == EQ_EXPR ? GE_EXPR : LT_EXPR,
if (code == LE_EXPR || code == GT_EXPR)
{
tree st;
- st = lang_hooks.types.signed_type (TREE_TYPE (arg1));
+ st = signed_type_for (TREE_TYPE (arg1));
return fold_build2 (code == LE_EXPR ? GE_EXPR : LT_EXPR,
type, fold_convert (st, arg0),
build_int_cst (st, 0));
if ((TREE_INT_CST_HIGH (arg1) & mask_hi) == mask_hi
&& (TREE_INT_CST_LOW (arg1) & mask_lo) == mask_lo)
{
- tem_type = lang_hooks.types.signed_type (TREE_TYPE (tem));
+ tem_type = signed_type_for (TREE_TYPE (tem));
tem = fold_convert (tem_type, tem);
}
else if ((TREE_INT_CST_HIGH (arg1) & mask_hi) == 0
#undef LANG_HOOKS_MARK_ADDRESSABLE
#undef LANG_HOOKS_TYPE_FOR_MODE
#undef LANG_HOOKS_TYPE_FOR_SIZE
-#undef LANG_HOOKS_SIGNED_TYPE
#undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
#undef LANG_HOOKS_CLEAR_BINDING_STACK
#undef LANG_HOOKS_GET_ALIAS_SET
#define LANG_HOOKS_MARK_ADDRESSABLE gfc_mark_addressable
#define LANG_HOOKS_TYPE_FOR_MODE gfc_type_for_mode
#define LANG_HOOKS_TYPE_FOR_SIZE gfc_type_for_size
-#define LANG_HOOKS_SIGNED_TYPE gfc_signed_type
#define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gfc_expand_function
#define LANG_HOOKS_CLEAR_BINDING_STACK gfc_clear_binding_stack
#define LANG_HOOKS_GET_ALIAS_SET gfc_get_alias_set
return NULL_TREE;
}
-/* Return a signed type the same as TYPE in other respects. */
-
-tree
-gfc_signed_type (tree type)
-{
- return get_signed_or_unsigned_type (0, type);
-}
-
#include "gt-fortran-trans-types.h"
tree gfc_type_for_size (unsigned, int);
tree gfc_type_for_mode (enum machine_mode, int);
-tree gfc_signed_type (tree);
tree gfc_get_element_type (tree);
tree gfc_get_array_type_bounds (tree, int, tree *, tree *, int);
extern bool java_mark_addressable (tree);
extern tree java_type_for_mode (enum machine_mode, int);
extern tree java_type_for_size (unsigned int, int);
-extern tree java_signed_type (tree);
extern tree java_truthvalue_conversion (tree);
extern void add_assume_compiled (const char *, int);
extern void add_enable_assert (const char *, int);
#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_TREE_DUMP_DUMP_TREE_FN
#define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN java_dump_tree
return 0;
}
-/* Return a signed type the same as TYPE in other respects. */
-
-tree
-java_signed_type (tree type)
-{
- return get_signed_or_unsigned_type (0, type);
-}
-
/* Mark EXP saying that we need to be able to take the
address of it; it should not be allocated in a register.
Value is true if successful. */
#define LANG_HOOKS_TREE_SIZE lhd_tree_size
#define LANG_HOOKS_TYPES_COMPATIBLE_P lhd_types_compatible_p
#define LANG_HOOKS_BUILTIN_FUNCTION lhd_builtin_function
-#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE lhd_signed_or_unsigned_type
#define LANG_HOOKS_EXPR_TO_DECL lhd_expr_to_decl
#define LANG_HOOKS_TO_TARGET_CHARSET lhd_to_target_charset
#define LANG_HOOKS_INIT_TS lhd_do_nothing
LANG_HOOKS_MAKE_TYPE, \
LANG_HOOKS_TYPE_FOR_MODE, \
LANG_HOOKS_TYPE_FOR_SIZE, \
- LANG_HOOKS_SIGNED_TYPE, \
- LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, \
LANG_HOOKS_GENERIC_TYPE_P, \
LANG_HOOKS_TYPE_PROMOTES_TO, \
LANG_HOOKS_REGISTER_BUILTIN_TYPE, \
lang_hooks.decls.pushdecl (decl);
return decl;
}
-
-/* If TYPE is an integral type, return an equivalent type which is
- unsigned iff UNSIGNEDP is true. If TYPE is not an integral type,
- return TYPE itself. */
-
-tree
-get_signed_or_unsigned_type (int unsignedp, tree type)
-{
- return lang_hooks.types.signed_or_unsigned_type(unsignedp, type);
-}
-
-/* Default implementation of the signed_or_unsigned_type language hook */
-
-tree
-lhd_signed_or_unsigned_type (int unsignedp, tree type)
-{
- if (!INTEGRAL_TYPE_P (type) || TYPE_UNSIGNED (type) == unsignedp)
- return type;
-
- return lang_hooks.types.type_for_size (TYPE_PRECISION (type), unsignedp);
-}
integer type with at least that precision. */
tree (*type_for_size) (unsigned, int);
- /* Given an integer type T, return a type like T but signed.
- If T is signed, the value is T. */
- tree (*signed_type) (tree);
-
- /* Return a type the same as TYPE except unsigned or signed
- according to UNSIGNEDP. */
- tree (*signed_or_unsigned_type) (int, tree);
-
/* True if the type is an instantiation of a generic type,
e.g. C++ template implicit specializations. */
bool (*generic_p) (tree);
int function_code, enum built_in_class cl,
const char *library_name,
tree attrs);
-extern tree lhd_signed_or_unsigned_type (int unsignedp, tree type);
#endif /* GCC_LANG_HOOKS_H */
return val;
}
+/* If TYPE is an integral type, return an equivalent type which is
+ unsigned iff UNSIGNEDP is true. If TYPE is not an integral type,
+ return TYPE itself. */
-/* Return an unsigned type the same as TYPE in other respects. */
-
-static tree
-get_unsigned_type (tree type)
+tree
+signed_or_unsigned_type_for (int unsignedp, tree type)
{
- return get_signed_or_unsigned_type (1, type);
+ tree t = type;
+ if (POINTER_TYPE_P (type))
+ t = size_type_node;
+
+ if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp)
+ return t;
+
+ return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp);
}
/* Returns unsigned variant of TYPE. */
tree
unsigned_type_for (tree type)
{
- if (POINTER_TYPE_P (type))
- return get_unsigned_type (size_type_node);
- return get_unsigned_type (type);
+ return signed_or_unsigned_type_for (1, type);
}
/* Returns signed variant of TYPE. */
tree
signed_type_for (tree type)
{
- if (POINTER_TYPE_P (type))
- return lang_hooks.types.signed_type (size_type_node);
- return lang_hooks.types.signed_type (type);
+ return signed_or_unsigned_type_for (0, type);
}
/* Returns the largest value obtainable by casting something in INNER type to
extern tree make_signed_type (int);
extern tree make_unsigned_type (int);
+extern tree signed_or_unsigned_type_for (int, tree);
extern tree signed_type_for (tree);
extern tree unsigned_type_for (tree);
extern void initialize_sizetypes (bool);
extern bool may_negate_without_overflow_p (tree);
extern tree get_inner_array_type (tree);
-extern tree get_signed_or_unsigned_type (int unsignedp, tree type);
-
/* From expmed.c. Since rtl.h is included after tree.h, we can't
put the prototype here. Rtl.h does declare the prototype if
tree.h had been included. */
static bool tree_mark_addressable (tree exp);
static tree tree_lang_type_for_size (unsigned precision, int unsignedp);
static tree tree_lang_type_for_mode (enum machine_mode mode, int unsignedp);
-static tree tree_lang_signed_type (tree type_node);
/* Functions to keep track of the current scope. */
static void pushlevel (int ignore);
#undef LANG_HOOKS_MARK_ADDRESSABLE
#define LANG_HOOKS_MARK_ADDRESSABLE tree_mark_addressable
-#undef LANG_HOOKS_SIGNED_TYPE
-#define LANG_HOOKS_SIGNED_TYPE tree_lang_signed_type
#undef LANG_HOOKS_TYPE_FOR_MODE
#define LANG_HOOKS_TYPE_FOR_MODE tree_lang_type_for_mode
#undef LANG_HOOKS_TYPE_FOR_SIZE
return NULL_TREE;
}
-/* Return the signed version of a TYPE_NODE, a scalar type. */
-
-static tree
-tree_lang_signed_type (tree type_node)
-{
- return tree_lang_type_for_size (TYPE_PRECISION (type_node), 0);
-}
-
\f
/* These functions and variables deal with binding contours. We only
need these functions for the list of PARM_DECLs, but we leave the