* gdbtypes.c (force_to_range_type): Use switch statement.
authorJim Kingdon <jkingdon@engr.sgi.com>
Sun, 26 Dec 1993 22:37:47 +0000 (22:37 +0000)
committerJim Kingdon <jkingdon@engr.sgi.com>
Sun, 26 Dec 1993 22:37:47 +0000 (22:37 +0000)
complain() not warning() if the TYPE_CODE isn't one we know how to
deal with gracefully.  Use builtin_type_int not
lookup_fundamental_type (the objfile we passed to
lookup_fundamental_type was sometimes NULL).

gdb/ChangeLog
gdb/gdbtypes.c

index 8c3cd8688e3d099eef7c988ed33fbb1df4f0deb3..dde00da8b4bef8db78b04685628d328be135bc3b 100644 (file)
@@ -1,5 +1,11 @@
 Sun Dec 26 09:18:10 1993  Jim Kingdon  (kingdon@lioth.cygnus.com)
 
+       * gdbtypes.c (force_to_range_type): Use switch statement.
+       complain() not warning() if the TYPE_CODE isn't one we know how to
+       deal with gracefully.  Use builtin_type_int not
+       lookup_fundamental_type (the objfile we passed to
+       lookup_fundamental_type was sometimes NULL).
+
        * valops.c (call_function_by_hand, push_word), defs.h (push_word),
        convex-xdep.c, m88k-nat.c, i386m3-nat.c, mips-tdep.c, mipsm3-nat.c,
        ns32km3-nat.c, remote-bug.c, m88k-tdep.c, remote-hms.c, remote-mips.c,
index b24d3e4e721f34854a88f3fbfeaad06d6cd101ad..e361796df8b32e2f259b0634218515a3cde80a36 100644 (file)
@@ -356,36 +356,44 @@ struct type *
 force_to_range_type (type)
      struct type *type;
 {
-  if (TYPE_CODE (type) == TYPE_CODE_RANGE)
-    return type;
-
-  if (TYPE_CODE (type) == TYPE_CODE_ENUM)
-    {
-      int low_bound = TYPE_FIELD_BITPOS (type, 0);
-      int high_bound = TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1);
-      struct type *range_type = create_range_type (NULL, type, low_bound, high_bound);
-      TYPE_NAME (range_type) = TYPE_NAME (range_type);
-      TYPE_DUMMY_RANGE (range_type) = 1;
-      return range_type;
-    }
-  if (TYPE_CODE (type) == TYPE_CODE_BOOL)
-    {
-      struct type *range_type = create_range_type (NULL, type, 0, 1);
-      TYPE_NAME (range_type) = TYPE_NAME (range_type);
-      TYPE_DUMMY_RANGE (range_type) = 1;
-      return range_type;
-    }
-  if (TYPE_CODE (type) == TYPE_CODE_CHAR)
+  switch (TYPE_CODE (type))
     {
-      struct type *range_type = create_range_type (NULL, type, 0, 255);
-      TYPE_NAME (range_type) = TYPE_NAME (range_type);
-      TYPE_DUMMY_RANGE (range_type) = 1;
-      return range_type;
-    }
+    case TYPE_CODE_RANGE:
+      return type;
+
+    case TYPE_CODE_ENUM:
+      {
+       int low_bound = TYPE_FIELD_BITPOS (type, 0);
+       int high_bound = TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1);
+       struct type *range_type =
+         create_range_type (NULL, type, low_bound, high_bound);
+       TYPE_NAME (range_type) = TYPE_NAME (range_type);
+       TYPE_DUMMY_RANGE (range_type) = 1;
+       return range_type;
+      }
+    case TYPE_CODE_BOOL:
+      {
+       struct type *range_type = create_range_type (NULL, type, 0, 1);
+       TYPE_NAME (range_type) = TYPE_NAME (range_type);
+       TYPE_DUMMY_RANGE (range_type) = 1;
+       return range_type;
+      }
+    case TYPE_CODE_CHAR:
+      {
+       struct type *range_type = create_range_type (NULL, type, 0, 255);
+       TYPE_NAME (range_type) = TYPE_NAME (range_type);
+       TYPE_DUMMY_RANGE (range_type) = 1;
+       return range_type;
+      }
+    default:
+      {
+       static struct complaint msg =
+         { "array index type must be a discrete type", 0, 0};
+       complain (&msg);
 
-  warning ("internal error:  array index type must be a discrete type");
-  type = lookup_fundamental_type (TYPE_OBJFILE (type), FT_INTEGER);
-  return create_range_type ((struct type *) NULL, type, 0, 0);
+       return create_range_type (NULL, builtin_type_int, 0, 0);
+      }
+    }
 }
 
 /* Create an array type using either a blank type supplied in RESULT_TYPE,