From 84fb43a1a4480e7a0a106fbe38144d1af50b476a Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 15 May 2009 09:11:40 +0000 Subject: dbxout.c (dbxout_range_type): Add LOW and HIGH parameters. * dbxout.c (dbxout_range_type): Add LOW and HIGH parameters. Use them for bounds. (print_int_cst_bounds_in_octal_p): Likewise. (dbxout_type): Adjust calls to above functions. Be prepared to deal with subtypes. * dwarf2out.c (base_type_die): Likewise. (is_subrange_type): Delete. (subrange_type_die): Add LOW and HIGH parameters. Use them for bounds. (modified_type_die): Call subrange_type_for_debug_p on subtypes. * fold-const.c (fold_truth_not_expr) : Do not strip it if the destination type is boolean. (build_range_check): Do not special-case subtypes. (fold_sign_changed_comparison): Likewise. (fold_unary): Likewise. * langhooks-def.h (LANG_HOOKS_GET_SUBRANGE_BOUNDS): Define. (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add LANG_HOOKS_GET_SUBRANGE_BOUNDS. * langhooks.h (lang_hooks_for_types): Add get_subrange_bounds. * tree.c (subrange_type_for_debug_p): New predicate based on the former is_subrange_type. * tree.h (subrange_type_for_debug_p): Declare. * tree-chrec.c (avoid_arithmetics_in_type_p): Delete. (convert_affine_scev): Remove call to above function. (chrec_convert_aggressive): Likewise. * tree-ssa.c (useless_type_conversion_p_1): Do not specifically return false for conversions involving subtypes. * tree-vrp.c (vrp_val_max): Do not special-case subtypes. (vrp_val_min): Likewise. (needs_overflow_infinity): Likewise. (extract_range_from_unary_expr): Likewise. ada/ * gcc-interface/ada-tree.h (TYPE_GCC_MIN_VALUE, TYPE_GCC_MAX_VALUE): New macros. (TYPE_RM_VALUES): Likewise. (TYPE_RM_SIZE): Rewrite in terms of TYPE_RM_VALUES. (SET_TYPE_RM_SIZE): New macro. (TYPE_RM_MIN_VALUE, TYPE_RM_MAX_VALUE): Likewise. (SET_TYPE_RM_SIZE, SET_TYPE_RM_MAX_VALUE): Likewise. (TYPE_MIN_VALUE, TYPE_MAX_VALUE): Redefine. * gcc-interface/gigi.h (create_range_type): Declare. * gcc-interface/decl.c (gnat_to_gnu_entity) Use SET_TYPE_RM_MAX_VALUE to set the upper bound on the UMT type. : Build a regular integer type first and then set the RM bounds. Use SET_TYPE_RM_SIZE to set the RM size. : Build a regular floating-point type first and then set the RM bounds. : Use create_range_type instead of build_range_type. : Build a regular integer type first and then set the RM bounds for the extra subtype. : Use create_range_type instead of build_range_type. : Set the RM bounds for enumeration types and the GCC bounds for floating-point types. (set_rm_size): Use SET_TYPE_RM_SIZE to set the RM size. (make_type_from_size) : Use SET_TYPE_RM_{MIN,MAX}_VALUE to set the bounds. Use SET_TYPE_RM_SIZE to set the RM size. (substitute_in_type) : Deal with GCC bounds for domain types and with RM bounds for subtypes. * gcc-interface/misc.c (LANG_HOOKS_GET_SUBRANGE_BOUNDS): Define. (gnat_print_type) : New case. : Fall through to above case. (gnat_get_subrange_bounds): New function. * gcc-interface/trans.c (add_decl_expr): Mark the trees rooted as TYPE_RM_MIN_VALUE and TYPE_RM_MAX_VALUE, if any. * gcc-interface/utils.c (gnat_init_decl_processing): Use precision 8 for booleans. Adjust and use SET_TYPE_RM_SIZE to set the RM size. (create_range_type): New function. (create_param_decl): Build a regular integer type first and then set the RM bounds for the extra subtype. (unchecked_convert): Remove kludge for 'Valid. * gcc-interface/utils2.c (build_binary_op) : Convert the index to sizetype instead of TYPE_DOMAIN. From-SVN: r147563 --- gcc/ada/gcc-interface/misc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gcc/ada/gcc-interface/misc.c') diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 5ccf134..bd6b51a 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -78,6 +78,7 @@ static int gnat_eh_type_covers (tree, tree); static void gnat_parse_file (int); static void internal_error_function (const char *, va_list *); static tree gnat_type_max_size (const_tree); +static void gnat_get_subrange_bounds (const_tree, tree *, tree *); /* Definitions for our language-specific hooks. */ @@ -125,6 +126,8 @@ static tree gnat_type_max_size (const_tree); #define LANG_HOOKS_TYPE_FOR_SIZE gnat_type_for_size #undef LANG_HOOKS_TYPES_COMPATIBLE_P #define LANG_HOOKS_TYPES_COMPATIBLE_P gnat_types_compatible_p +#undef LANG_HOOKS_GET_SUBRANGE_BOUNDS +#define LANG_HOOKS_GET_SUBRANGE_BOUNDS gnat_get_subrange_bounds #undef LANG_HOOKS_ATTRIBUTE_TABLE #define LANG_HOOKS_ATTRIBUTE_TABLE gnat_internal_attribute_table #undef LANG_HOOKS_BUILTIN_FUNCTION @@ -513,6 +516,12 @@ gnat_print_type (FILE *file, tree node, int indent) case ENUMERAL_TYPE: case BOOLEAN_TYPE: print_node_brief (file, "RM size", TYPE_RM_SIZE (node), indent + 4); + + /* ... fall through ... */ + + case REAL_TYPE: + print_node_brief (file, "RM min", TYPE_RM_MIN_VALUE (node), indent + 4); + print_node_brief (file, "RM max", TYPE_RM_MAX_VALUE (node), indent + 4); break; case ARRAY_TYPE: @@ -644,6 +653,18 @@ gnat_type_max_size (const_tree gnu_type) return max_unitsize; } +/* GNU_TYPE is a subtype of an integral type. Set LOWVAL to the low bound + and HIGHVAL to the high bound, respectively. */ + +static void +gnat_get_subrange_bounds (const_tree gnu_type, tree *lowval, tree *highval) +{ + tree min = TYPE_MIN_VALUE (gnu_type); + tree max = TYPE_MAX_VALUE (gnu_type); + *lowval = TREE_CONSTANT (min) ? min : TYPE_GCC_MIN_VALUE (gnu_type); + *highval = TREE_CONSTANT (max) ? max : TYPE_GCC_MAX_VALUE (gnu_type); +} + /* GNU_TYPE is a type. Determine if it should be passed by reference by default. */ -- cgit v1.1