This is another regression in the debug info, this time introduced on the
mainline by my patch toggling the signedness of Character in Ada.
Tested on x86_64-suse-linux, applied on the mainline.
2016-02-16 Eric Botcazou <ebotca...@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.
--
Eric Botcazou
Index: gcc-interface/gigi.h
===================================================================
--- gcc-interface/gigi.h (revision 233448)
+++ gcc-interface/gigi.h (working copy)
@@ -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;
+}
Index: gcc-interface/misc.c
===================================================================
--- gcc-interface/misc.c (revision 233467)
+++ gcc-interface/misc.c (working copy)
@@ -786,8 +786,7 @@ gnat_get_array_descr_info (const_tree co
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 co
}
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 co
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;
}
Index: gcc-interface/utils.c
===================================================================
--- gcc-interface/utils.c (revision 233448)
+++ gcc-interface/utils.c (working copy)
@@ -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);