]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gigi.h (maybe_debug_type): New inline function.
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 16 Feb 2016 18:01:04 +0000 (18:01 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 16 Feb 2016 18:01:04 +0000 (18:01 +0000)
* 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

gcc/ada/ChangeLog
gcc/ada/gcc-interface/gigi.h
gcc/ada/gcc-interface/misc.c
gcc/ada/gcc-interface/utils.c

index 4ed1903d72667200791da30413d3a16c6fa68a58..b2e9726a05f8c32ea93025b074cb8c47c27bf059 100644 (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.
index a55b1b03717d0089cb09ac4b30a9c2cbed7c037e..00b7c6a66bef3860b5fc814fd70515844ed7f1e6 100644 (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;
+}
index f54e390ecf52d6854f648093d4a91b4a8a9aff73..61a61fad40fc06ce96fb12ca5562c283243938a9 100644 (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;
     }
 
index a62d9c240731f1964a3a9d2d4feff840d695b010..ff21e7b5ff05f2cae41251b151603b0d222baed5 100644 (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);