summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/ChangeLog9
-rw-r--r--gcc/ada/gcc-interface/gigi.h11
-rw-r--r--gcc/ada/gcc-interface/misc.c18
-rw-r--r--gcc/ada/gcc-interface/utils.c7
4 files changed, 34 insertions, 11 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 4ed1903d726..b2e9726a05f 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,14 @@
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.
(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define to above.
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index a55b1b03717..00b7c6a66be 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -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;
+}
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index f54e390ecf5..61a61fad40f 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -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;
}
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index a62d9c24073..ff21e7b5ff0 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -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);