aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/misc.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-01-18 11:10:42 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-01-18 11:10:42 +0000
commit7c775aca298673f95dddfb8605f11b0e2f236361 (patch)
tree0bffe85bad394e4bb7306e24515f3f47f8dfe5d1 /gcc/ada/gcc-interface/misc.c
parent3dd5f42e90fa6e296d233b0f05c3a760a45d1313 (diff)
downloadgcc-7c775aca298673f95dddfb8605f11b0e2f236361.zip
gcc-7c775aca298673f95dddfb8605f11b0e2f236361.tar.gz
gcc-7c775aca298673f95dddfb8605f11b0e2f236361.tar.bz2
ada-tree.h (TYPE_IMPLEMENTS_PACKED_ARRAY_P): Rename to
* gcc-interface/ada-tree.h (TYPE_IMPLEMENTS_PACKED_ARRAY_P): Rename to (TYPE_IMPL_PACKED_ARRAY_P): ...this. (TYPE_CAN_HAVE_DEBUG_TYPE_P): Do not test TYPE_DEBUG_TYPE. * gcc-interface/decl.c (gnat_to_gnu_entity): Simplify NULL_TREE tests and tweak gnat_encodings tests throughout. (initial_value_needs_conversion): Likewise. (intrin_arglists_compatible_p): Likewise. * gcc-interface/misc.c (gnat_print_type): Likewise. (gnat_get_debug_type): Likewise. (gnat_get_fixed_point_type_info): Likewise. (gnat_get_array_descr_info): Likewise. (get_array_bit_stride): Likewise. (gnat_get_type_bias): Fix formatting. (enumerate_modes): Likewise. * gcc-interface/trans.c (gnat_to_gnu): Likewise. (add_decl_expr): Simplify NULL_TREE test. (end_stmt_group): Likewise. (build_binary_op_trapv): Fix formatting. (get_exception_label): Use switch statement. (init_code_table): Move around. * gcc-interface/utils.c (global_bindings_p): Simplify NULL_TREE test. (gnat_poplevel): Likewise. (gnat_set_type_context): Likewise. (defer_or_set_type_context): Fix formatting. (gnat_pushdecl): Simplify NULL_TREE test. (maybe_pad_type): Likewise. (add_parallel_type): Likewise. (create_range_type): Likewise. (process_deferred_decl_context): Likewise. (convert): Likewise. (def_builtin_1): Likewise. * gcc-interface/utils2.c (find_common_type): Likewise. (build_binary_op): Likewise. (gnat_rewrite_reference): Likewise. (get_inner_constant_reference): Likewise. From-SVN: r232501
Diffstat (limited to 'gcc/ada/gcc-interface/misc.c')
-rw-r--r--gcc/ada/gcc-interface/misc.c93
1 files changed, 45 insertions, 48 deletions
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index adaea7f..f051c0c 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -6,7 +6,7 @@
* *
* C Implementation File *
* *
- * Copyright (C) 1992-2015, Free Software Foundation, Inc. *
+ * Copyright (C) 1992-2016, Free Software Foundation, Inc. *
* *
* GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- *
@@ -112,8 +112,8 @@ gnat_parse_file (void)
/* ??? Call the SEH initialization routine. This is to workaround
a bootstrap path problem. The call below should be removed at some
- point and the SEH pointer passed to __gnat_initialize() above. */
- __gnat_install_SEH_handler((void *)seh);
+ point and the SEH pointer passed to __gnat_initialize above. */
+ __gnat_install_SEH_handler ((void *)seh);
/* Call the front-end elaboration procedures. */
adainit ();
@@ -528,10 +528,10 @@ gnat_print_type (FILE *file, tree node, int indent)
break;
}
- if (TYPE_CAN_HAVE_DEBUG_TYPE_P (node) && TYPE_DEBUG_TYPE (node) != NULL_TREE)
+ if (TYPE_CAN_HAVE_DEBUG_TYPE_P (node) && TYPE_DEBUG_TYPE (node))
print_node_brief (file, "debug type", TYPE_DEBUG_TYPE (node), indent + 4);
- else if (TYPE_IMPLEMENTS_PACKED_ARRAY_P (node)
- && TYPE_ORIGINAL_PACKED_ARRAY (node) != NULL_TREE)
+
+ if (TYPE_IMPL_PACKED_ARRAY_P (node) && TYPE_ORIGINAL_PACKED_ARRAY (node))
print_node_brief (file, "original packed array",
TYPE_ORIGINAL_PACKED_ARRAY (node), indent + 4);
}
@@ -575,23 +575,25 @@ gnat_descriptive_type (const_tree type)
return NULL_TREE;
}
-/* Return the type to used for debugging information instead of TYPE, if any.
+/* Return the type to be used for debugging information instead of TYPE or
NULL_TREE if TYPE is fine. */
static tree
gnat_get_debug_type (const_tree type)
{
- if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type))
+ if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type) && TYPE_DEBUG_TYPE (type))
{
type = TYPE_DEBUG_TYPE (type);
- /* ??? Kludge: the get_debug_type language hook is processed after the
- array descriptor language hook, so if there is an array behind this
- type, the latter is supposed to handle it. Still, we can get here
- with a type we are not supposed to handle (when the DWARF back-end
+
+ /* ??? The get_debug_type language hook is processed after the array
+ descriptor language hook, so if there is an array behind this type,
+ the latter is supposed to handle it. Still, we can get here with
+ a type we are not supposed to handle (e.g. when the DWARF back-end
processes the type of a variable), so keep this guard. */
- if (type != NULL_TREE && !TYPE_IMPLEMENTS_PACKED_ARRAY_P (type))
+ if (type && TYPE_CAN_HAVE_DEBUG_TYPE_P (type))
return const_cast<tree> (type);
}
+
return NULL_TREE;
}
@@ -606,8 +608,8 @@ gnat_get_fixed_point_type_info (const_tree type,
/* GDB cannot handle fixed-point types yet, so rely on GNAT encodings
instead for it. */
- if (gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL
- || !TYPE_IS_FIXED_POINT_P (type))
+ if (!TYPE_IS_FIXED_POINT_P (type)
+ || gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
return false;
scale_factor = TYPE_SCALE_FACTOR (type);
@@ -640,6 +642,7 @@ gnat_get_fixed_point_type_info (const_tree type,
gcc_assert (num == integer_one_node
&& TREE_CODE (base) == INTEGER_CST
&& TREE_CODE (exponent) == INTEGER_CST);
+
switch (tree_to_shwi (base))
{
case 2:
@@ -661,6 +664,7 @@ gnat_get_fixed_point_type_info (const_tree type,
expect N / D with constant operands. */
gcc_assert (TREE_CODE (num) == INTEGER_CST
&& TREE_CODE (den) == INTEGER_CST);
+
info->scale_factor_kind = fixed_point_scale_factor_arbitrary;
info->scale_factor.arbitrary.numerator = tree_to_uhwi (num);
info->scale_factor.arbitrary.denominator = tree_to_shwi (den);
@@ -746,7 +750,7 @@ gnat_type_max_size (const_tree gnu_type)
return max_unitsize;
}
-static tree get_array_bit_stride (tree comp_type);
+static tree get_array_bit_stride (tree);
/* Provide information in INFO for debug output about the TYPE array type.
Return whether TYPE is handled. */
@@ -759,9 +763,7 @@ gnat_get_array_descr_info (const_tree const_type,
bool is_array = false;
bool is_fat_ptr = false;
bool is_packed_array = false;
-
tree type = const_cast<tree> (const_type);
-
const_tree first_dimen = NULL_TREE;
const_tree last_dimen = NULL_TREE;
const_tree dimen;
@@ -774,18 +776,16 @@ gnat_get_array_descr_info (const_tree const_type,
tree thinptr_template_expr = NULL_TREE;
tree thinptr_bound_field = NULL_TREE;
- /* ??? Kludge: see gnat_get_debug_type. */
- if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type)
- && TYPE_DEBUG_TYPE (type) != NULL_TREE)
+ /* ??? See gnat_get_debug_type. */
+ if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type) && TYPE_DEBUG_TYPE (type))
type = TYPE_DEBUG_TYPE (type);
/* If we have an implementation type for a packed array, get the orignial
array type. */
- if (TYPE_IMPLEMENTS_PACKED_ARRAY_P (type)
- && TYPE_ORIGINAL_PACKED_ARRAY (type) != NULL_TREE)
+ if (TYPE_IMPL_PACKED_ARRAY_P (type) && TYPE_ORIGINAL_PACKED_ARRAY (type))
{
- is_packed_array = true;
type = TYPE_ORIGINAL_PACKED_ARRAY (type);
+ is_packed_array = true;
}
/* First pass: gather all information about this array except everything
@@ -801,8 +801,8 @@ gnat_get_array_descr_info (const_tree const_type,
info->data_location = NULL_TREE;
}
- else if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL
- && TYPE_IS_FAT_POINTER_P (type))
+ else if (TYPE_IS_FAT_POINTER_P (type)
+ && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
{
const tree ua_type = TYPE_UNCONSTRAINED_ARRAY (type);
@@ -828,9 +828,9 @@ gnat_get_array_descr_info (const_tree const_type,
them to appear in the debug info as pointers to an array type. That's why
we match only the RECORD_TYPE here instead of the POINTER_TYPE with the
TYPE_IS_THIN_POINTER_P predicate. */
- else if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL
- && TREE_CODE (type) == RECORD_TYPE
- && TYPE_CONTAINS_TEMPLATE_P (type))
+ else if (TREE_CODE (type) == RECORD_TYPE
+ && TYPE_CONTAINS_TEMPLATE_P (type)
+ && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
{
/* This will be our base object address. Note that we assume that
pointers to these will actually point to the array field (thin
@@ -910,9 +910,7 @@ gnat_get_array_descr_info (const_tree const_type,
structure. */
for (i = (convention_fortran_p ? info->ndimensions - 1 : 0),
dimen = first_dimen;
-
0 <= i && i < info->ndimensions;
-
i += (convention_fortran_p ? -1 : 1),
dimen = TREE_TYPE (dimen))
{
@@ -927,12 +925,10 @@ gnat_get_array_descr_info (const_tree const_type,
there are two cases where we generate self-referencial bound
expressions: arrays that are constrained by record discriminants
and XUA types. */
- const bool is_xua_type =
- (TYPE_CONTEXT (first_dimen) != NULL_TREE
- && TREE_CODE (TYPE_CONTEXT (first_dimen)) != RECORD_TYPE
- && contains_placeholder_p (TYPE_MIN_VALUE (index_type)));
-
- if (is_xua_type && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
+ if (TYPE_CONTEXT (first_dimen)
+ && TREE_CODE (TYPE_CONTEXT (first_dimen)) != RECORD_TYPE
+ && contains_placeholder_p (TYPE_MIN_VALUE (index_type))
+ && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
{
info->dimen[i].lower_bound = NULL_TREE;
info->dimen[i].upper_bound = NULL_TREE;
@@ -960,9 +956,10 @@ gnat_get_array_descr_info (const_tree const_type,
/* The DWARF back-end will output exactly INDEX_TYPE as the array index'
"root" type, so pell subtypes when possible. */
- while (TREE_TYPE (index_type) != NULL_TREE
+ while (TREE_TYPE (index_type)
&& !subrange_type_for_debug_p (index_type, NULL, NULL))
index_type = TREE_TYPE (index_type);
+
info->dimen[i].bounds_type = index_type;
info->dimen[i].stride = NULL_TREE;
}
@@ -980,9 +977,9 @@ gnat_get_array_descr_info (const_tree const_type,
element. This is why we emit a stride in such situations. */
tree source_element_type = info->element_type;
- while (1)
+ while (true)
{
- if (TYPE_DEBUG_TYPE (source_element_type) != NULL_TREE)
+ if (TYPE_DEBUG_TYPE (source_element_type))
source_element_type = TYPE_DEBUG_TYPE (source_element_type);
else if (TYPE_IS_PADDING_P (source_element_type))
source_element_type
@@ -1024,11 +1021,9 @@ get_array_bit_stride (tree comp_type)
if (INTEGRAL_TYPE_P (comp_type))
return TYPE_RM_SIZE (comp_type);
- /* Otherwise, see if this is an array we can analyze. */
+ /* Otherwise, see if this is an array we can analyze; if it's not, punt. */
memset (&info, 0, sizeof (info));
- if (!gnat_get_array_descr_info (comp_type, &info)
- || info.stride == NULL_TREE)
- /* If it's not, give it up. */
+ if (!gnat_get_array_descr_info (comp_type, &info) || !info.stride)
return NULL_TREE;
/* Otherwise, the array stride is the inner array's stride multiplied by the
@@ -1047,8 +1042,7 @@ get_array_bit_stride (tree comp_type)
{
tree count;
- if (info.dimen[i].lower_bound == NULL_TREE
- || info.dimen[i].upper_bound == NULL_TREE)
+ if (!info.dimen[i].lower_bound || !info.dimen[i].upper_bound)
return NULL_TREE;
/* Put in count an expression that computes the length of this
@@ -1080,13 +1074,16 @@ gnat_get_subrange_bounds (const_tree gnu_type, tree *lowval, tree *highval)
*highval = TYPE_MAX_VALUE (gnu_type);
}
+/* Return the bias of GNU_TYPE, if any. */
+
static tree
gnat_get_type_bias (const_tree gnu_type)
{
if (TREE_CODE (gnu_type) == INTEGER_TYPE
&& TYPE_BIASED_REPRESENTATION_P (gnu_type)
&& gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
- return TYPE_RM_MIN_VALUE(gnu_type);
+ return TYPE_RM_MIN_VALUE (gnu_type);
+
return NULL_TREE;
}
@@ -1240,7 +1237,7 @@ enumerate_modes (void (*f) (const char *, int, int, int, int, int, int, int))
digs = fmt->p;
else
- gcc_unreachable();
+ gcc_unreachable ();
}
/* First register any C types for this mode that the front end