aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r--gdb/gdbtypes.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index a21f959..13a111f 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -356,8 +356,18 @@ get_discrete_bounds (type, lowp, highp)
case TYPE_CODE_ENUM:
if (TYPE_NFIELDS (type) > 0)
{
- *lowp = TYPE_FIELD_BITPOS (type, 0);
- *highp = TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1);
+ /* The enums may not be sorted by value, so search all
+ entries */
+ int i;
+
+ *lowp = *highp = TYPE_FIELD_BITPOS (type, 0);
+ for (i = 0; i < TYPE_NFIELDS (type); i++)
+ {
+ if (TYPE_FIELD_BITPOS (type, i) < *lowp)
+ *lowp = TYPE_FIELD_BITPOS (type, i);
+ if (TYPE_FIELD_BITPOS (type, i) > *highp)
+ *highp = TYPE_FIELD_BITPOS (type, i);
+ }
}
else
{