From cfabbd351a174406fd5aa063303f5c8bf9266bbc Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 17 Oct 2020 11:41:59 -0600 Subject: [PATCH] Make range types inherit signed-ness from base type I ran across this comment in valprint.c: /* FIXME: create_static_range_type does not set the unsigned bit in a range type (I think it probably should copy it from the target type), so we won't print values which are too large to fit in a signed integer correctly. */ It seems to me that a range type ought to inherit its signed-ness from the underlying type, so this patch implements this change, and removes the comment. (It was also copied into m2-valprint.c.) I also remove the comment about handling ranges of enums, because I think that comment is incorrect. gdb/ChangeLog 2020-10-17 Tom Tromey * valprint.c (generic_value_print): Remove comment. * m2-valprint.c (m2_value_print_inner): Remove comment. * gdbtypes.c (create_range_type): Set TYPE_UNSIGNED from base type. --- gdb/ChangeLog | 7 +++++++ gdb/gdbtypes.c | 11 +---------- gdb/m2-valprint.c | 7 ------- gdb/valprint.c | 10 ---------- 4 files changed, 8 insertions(+), 27 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9ed649314f5..fc4b716fff3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2020-10-17 Tom Tromey + + * valprint.c (generic_value_print): Remove comment. + * m2-valprint.c (m2_value_print_inner): Remove comment. + * gdbtypes.c (create_range_type): Set TYPE_UNSIGNED from base + type. + 2020-10-17 Tom de Vries PR symtab/26317 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 43c05d344d0..e7d9e4cef3e 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -950,16 +950,7 @@ create_range_type (struct type *result_type, struct type *index_type, result_type->set_bounds (bounds); - if (low_bound->kind () == PROP_CONST && low_bound->const_val () >= 0) - result_type->set_is_unsigned (true); - - /* Ada allows the declaration of range types whose upper bound is - less than the lower bound, so checking the lower bound is not - enough. Make sure we do not mark a range type whose upper bound - is negative as unsigned. */ - if (high_bound->kind () == PROP_CONST && high_bound->const_val () < 0) - result_type->set_is_unsigned (false); - + result_type->set_is_unsigned (index_type->is_unsigned ()); result_type->set_endianity_is_not_default (index_type->endianity_is_not_default ()); diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index 9f5ce7e9a27..c285543f4bf 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -448,13 +448,6 @@ m2_value_print_inner (struct value *val, struct ui_file *stream, int recurse, m2_value_print_inner (v, stream, recurse, options); break; } - /* FIXME: create_static_range_type does not set the unsigned bit in a - range type (I think it probably should copy it from the target - type), so we won't print values which are too large to - fit in a signed integer correctly. */ - /* FIXME: Doesn't handle ranges of enums correctly. (Can't just - print with the target type, though, because the size of our type - and the target type might differ). */ /* FALLTHROUGH */ case TYPE_CODE_REF: diff --git a/gdb/valprint.c b/gdb/valprint.c index 0749f38983e..dd70a1a3933 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -893,16 +893,6 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_RANGE: - /* FIXME: create_static_range_type does not set the unsigned bit in a - range type (I think it probably should copy it from the - target type), so we won't print values which are too large to - fit in a signed integer correctly. */ - /* FIXME: Doesn't handle ranges of enums correctly. (Can't just - print with the target type, though, because the size of our - type and the target type might differ). */ - - /* FALLTHROUGH */ - case TYPE_CODE_INT: generic_value_print_int (val, stream, options); break; -- 2.43.5