* event-loop.c: Include unistd.h if it exists.
[deliverable/binutils-gdb.git] / gdb / ada-typeprint.c
index 9fabd68515b8a4e9e7e57c3897e2cc51830a41e1..02f50bbb7d2df4abfa840deff7246cde7cb8f995 100644 (file)
@@ -114,53 +114,32 @@ decoded_type_name (struct type *type)
     }
 }
 
-/* Print range type TYPE on STREAM.  */
+/* Print TYPE on STREAM, preferably as a range.  */
 
 static void
 print_range (struct type *type, struct ui_file *stream)
 {
-  struct type *target_type;
-  target_type = TYPE_TARGET_TYPE (type);
-  if (target_type == NULL)
-    target_type = type;
-
-  switch (TYPE_CODE (target_type))
+  switch (TYPE_CODE (type))
     {
     case TYPE_CODE_RANGE:
-    case TYPE_CODE_INT:
-    case TYPE_CODE_BOOL:
-    case TYPE_CODE_CHAR:
     case TYPE_CODE_ENUM:
+      {
+       struct type *target_type;
+       target_type = TYPE_TARGET_TYPE (type);
+       if (target_type == NULL)
+         target_type = type;
+       ada_print_scalar (target_type, ada_discrete_type_low_bound (type),
+                         stream);
+       fprintf_filtered (stream, " .. ");
+       ada_print_scalar (target_type, ada_discrete_type_high_bound (type),
+                         stream);
+      }
       break;
     default:
-      target_type = NULL;
-      break;
-    }
-
-  if (TYPE_NFIELDS (type) < 2)
-    {
-      /* A range needs at least 2 bounds to be printed.  If there are less
-         than 2, just print the type name instead of the range itself.
-         This check handles cases such as characters, for example.
-
-         If the name is not defined, then we don't print anything.
-       */
       fprintf_filtered (stream, "%.*s",
                        ada_name_prefix_len (TYPE_NAME (type)),
                        TYPE_NAME (type));
-    }
-  else
-    {
-      /* We extract the range type bounds respectively from the first element
-         and the last element of the type->fields array */
-      const LONGEST lower_bound = (LONGEST) TYPE_LOW_BOUND (type);
-      const LONGEST upper_bound = (TYPE_CODE (type) == TYPE_CODE_RANGE
-       ? (LONGEST) TYPE_HIGH_BOUND (type)
-       : (LONGEST) TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1));
-
-      ada_print_scalar (target_type, lower_bound, stream);
-      fprintf_filtered (stream, " .. ");
-      ada_print_scalar (target_type, upper_bound, stream);
+      break;
     }
 }
 
@@ -352,7 +331,7 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
   int bitsize;
   int n_indices;
 
-  if (ada_is_packed_array_type (type))
+  if (ada_is_constrained_packed_array_type (type))
     type = ada_coerce_to_simple_array_type (type);
 
   bitsize = 0;
@@ -770,7 +749,7 @@ ada_print_type (struct type *type0, char *varstring, struct ui_file *stream,
 
   if (ada_is_aligner_type (type))
     ada_print_type (ada_aligned_type (type), "", stream, show, level);
-  else if (ada_is_packed_array_type (type))
+  else if (ada_is_constrained_packed_array_type (type))
     {
       if (TYPE_CODE (type) == TYPE_CODE_PTR)
         {
This page took 0.024609 seconds and 4 git commands to generate.