* dwarf2read.c (struct attribute): Increase sizes of unsnd and snd
[deliverable/binutils-gdb.git] / gdb / ada-typeprint.c
index fe902e2e684e0b4fa9398eecd917cfcac4d302fb..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;
     }
 }
 
This page took 0.030565 seconds and 4 git commands to generate.