gdb/dwarf: Ensure the target type of ranges is not void
If a DW_TAG_subrange_type DWARF entry has no DW_AT_type then a default
type based on the size of an address on the current target is assumed.
We store this type as the target type for GDB's range types.
Currently GDB can create ranges for which the target type is VOID,
this is incorrect but seems to cause no problems. I believe the reason
this doesn't cause any issues is because the languages (for example
Ada) that actually make use of a ranges target type also have
compilers that generate DWARF that includes a DW_AT_type attribute.
However, gfortran does not include a DW_AT_type, its DWARF instead
relies on the default target type. This isn't currently a problem for
GDB as gfortran doesn't make use of the target type when printing
subranges, but it shouldn't hurt to fix this issue now.
I've added an assert into create_range_type that will catch this issue
if it comes up again.
This was tested on an x86-64/GNU-Linux machine with both the Ada and
gfortran compilers available with both '--target_board=unix' and
'--target_board=unix/-m32'. There are no user visible changes after
this commit.
gdb/ChangeLog:
* dwarf2read.c (read_subrange_index_type): New function.
(read_subrange_type): Move code into new function and call it.
* gdbtypes.c (create_range_type): Add some asserts.