diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-12-26 22:37:47 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-12-26 22:37:47 +0000 |
commit | 54613301478dbe930e8d834e8423f68a44622989 (patch) | |
tree | 4f4fb851dde83d64b4621e3c2a324fde4838bba6 /gdb/gdbtypes.c | |
parent | 45db9cafcf0751639969e67a2bb7061aa3630347 (diff) | |
download | fsf-binutils-gdb-54613301478dbe930e8d834e8423f68a44622989.zip fsf-binutils-gdb-54613301478dbe930e8d834e8423f68a44622989.tar.gz fsf-binutils-gdb-54613301478dbe930e8d834e8423f68a44622989.tar.bz2 |
* 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).
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r-- | gdb/gdbtypes.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b24d3e4..e361796 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -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, |