gigi.h (maybe_debug_type): New inline function.

* gcc-interface/gigi.h (maybe_debug_type): New inline function.
	* gcc-interface/misc.c (gnat_get_array_descr_info): Use it.
	Call maybe_character_value on the array bounds.  Get to the base type
	of the index type and call maybe_debug_type on it.
	* gcc-interface/utils.c (finish_character_type): Add special treatment

From-SVN: r233469
This commit is contained in:
Eric Botcazou 2016-02-16 18:01:04 +00:00 committed by Eric Botcazou
parent 8c7eac6260
commit 7005800cd1
4 changed files with 34 additions and 11 deletions

View File

@ -1,3 +1,12 @@
2016-02-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (maybe_debug_type): New inline function.
* gcc-interface/misc.c (gnat_get_array_descr_info): Use it.
Call maybe_character_value on the array bounds. Get to the base type
of the index type and call maybe_debug_type on it.
* gcc-interface/utils.c (finish_character_type): Add special treatment
for char_type_node.
2016-02-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/misc.c (gnat_enum_underlying_base_type): New function.

View File

@ -1164,3 +1164,14 @@ maybe_character_value (tree expr)
return expr;
}
/* Return the debug type of TYPE if it exists, otherwise TYPE itself. */
static inline tree
maybe_debug_type (tree type)
{
if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type) && TYPE_DEBUG_TYPE (type))
type = TYPE_DEBUG_TYPE (type);
return type;
}

View File

@ -786,8 +786,7 @@ gnat_get_array_descr_info (const_tree const_type,
tree thinptr_bound_field = NULL_TREE;
/* ??? See gnat_get_debug_type. */
if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type) && TYPE_DEBUG_TYPE (type))
type = TYPE_DEBUG_TYPE (type);
type = maybe_debug_type (type);
/* If we have an implementation type for a packed array, get the orignial
array type. */
@ -944,8 +943,10 @@ gnat_get_array_descr_info (const_tree const_type,
}
else
{
info->dimen[i].lower_bound = TYPE_MIN_VALUE (index_type);
info->dimen[i].upper_bound = TYPE_MAX_VALUE (index_type);
info->dimen[i].lower_bound
= maybe_character_value (TYPE_MIN_VALUE (index_type));
info->dimen[i].upper_bound
= maybe_character_value (TYPE_MAX_VALUE (index_type));
}
}
@ -963,13 +964,12 @@ gnat_get_array_descr_info (const_tree const_type,
thinptr_bound_field = DECL_CHAIN (thinptr_bound_field);
}
/* 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)
&& !subrange_type_for_debug_p (index_type, NULL, NULL))
/* The DWARF back-end will output BOUNDS_TYPE as the base type of
the array index, so get to the base type of INDEX_TYPE. */
while (TREE_TYPE (index_type))
index_type = TREE_TYPE (index_type);
info->dimen[i].bounds_type = index_type;
info->dimen[i].bounds_type = maybe_debug_type (index_type);
info->dimen[i].stride = NULL_TREE;
}

View File

@ -1625,8 +1625,11 @@ finish_character_type (tree char_type)
if (TYPE_UNSIGNED (char_type))
return;
/* Make a copy of the unsigned version since we'll modify it below. */
tree unsigned_char_type = copy_type (gnat_unsigned_type_for (char_type));
/* Make a copy of a generic unsigned version since we'll modify it. */
tree unsigned_char_type
= (char_type == char_type_node
? unsigned_char_type_node
: copy_type (gnat_unsigned_type_for (char_type)));
TYPE_NAME (unsigned_char_type) = TYPE_NAME (char_type);
TYPE_STRING_FLAG (unsigned_char_type) = TYPE_STRING_FLAG (char_type);