diff options
author | Nils-Christian Kempke <nils-christian.kempke@intel.com> | 2022-04-11 14:06:56 +0200 |
---|---|---|
committer | Nils-Christian Kempke <nils-christian.kempke@intel.com> | 2022-04-11 14:06:56 +0200 |
commit | adc29023a741fbeb23dc3e07a0328cca4e9061f1 (patch) | |
tree | c0d986d6c03c24859ef2569bf163680ec40f3418 /gdb/testsuite/gdb.fortran | |
parent | 4ec8aa9e94858144a4ca831ae810d741a172d4b7 (diff) | |
download | gdb-adc29023a741fbeb23dc3e07a0328cca4e9061f1.zip gdb-adc29023a741fbeb23dc3e07a0328cca4e9061f1.tar.gz gdb-adc29023a741fbeb23dc3e07a0328cca4e9061f1.tar.bz2 |
gdb/fortran: clean-up Fortran intrinsic types
The currently implemented intrinsic type handling for Fortran missed some
tokens and their parsing. While still not all Fortran type kinds are
implemented this patch at least makes the currently handled types
consistent. As an example for what this patch does, consider the
intrinsic type INTEGER. GDB implemented the handling of the
keywords "integer" and "integer_2" but missed "integer_4" and "integer_8"
even though their corresponding internal types were already available as
the Fortran builtin types builtin_integer and builtin_integer_s8.
Similar problems applied to LOGICAL, REAL, and COMPLEX. This patch adds
all missing tokens and their parsing. Whenever a section containing the
type handling was touched, it also was reordered to be in a more easy to
grasp order. All INTEGER/REAL/LOGICAL/COMPLEX types were grouped
together and ordered ascending in their size making a missing one more
easy to spot.
Before this change GDB would print the following when tyring to use the
INTEGER keywords:
(gdb) set language fortran
(gdb) ptype integer*1
unsupported kind 1 for type integer
(gdb) ptype integer_1
No symbol table is loaded. Use the "file" command.
(gdb) ptype integer*2
type = integer*2
(gdb) ptype integer_2
type = integer*2
(gdb) ptype integer*4
type = integer
(gdb) ptype integer_4
No symbol table is loaded. Use the "file" command.
(gdb) ptype integer*8
type = integer*8
(gdb) ptype integer_8
No symbol table is loaded. Use the "file" command.
(gdb) ptype integer
type = integer
With this patch all keywords are available and the GDB prints:
(gdb) set language fortran
(gdb) ptype integer*1
type = integer*1
(gdb) ptype integer_1
type = integer*1
(gdb) ptype integer*2
type = integer*2
(gdb) ptype integer_2
type = integer*2
(gdb) ptype integer*4
type = integer*4
(gdb) ptype integer_4
type = integer*4
(gdb) ptype integer*8
type = integer*8
(gdb) ptype integer_8
type = integer*8
(gdb) ptype integer
type = integer
The described changes have been applied to INTEGER, REAL, COMPLEX,
and LOGICAL. Existing testcases have been adapted to reflect the
new behavior. Tests for formerly missing types have been added.
Diffstat (limited to 'gdb/testsuite/gdb.fortran')
-rw-r--r-- | gdb/testsuite/gdb.fortran/types.exp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/gdb/testsuite/gdb.fortran/types.exp b/gdb/testsuite/gdb.fortran/types.exp index 8122cbc..5ab44b1 100644 --- a/gdb/testsuite/gdb.fortran/types.exp +++ b/gdb/testsuite/gdb.fortran/types.exp @@ -71,13 +71,35 @@ proc test_float_literal_types_accepted {} { gdb_test "pt 10e20" "type = real\\*\[0-9\]+" } +# Test the default primitive Fortran types. +proc test_default_types {} { + gdb_test "ptype integer*4" "type = integer" + gdb_test "ptype integer_4" "type = integer" + + gdb_test "ptype logical" "type = logical*4" + + gdb_test "ptype real*4" "type = real" + gdb_test "ptype real_4" "type = real" + + gdb_test "ptype complex" "type = complex*4" +} + # Test the the primitive Fortran types, those that GDB should always # know, even if the program does not define them, are in fact, known. proc test_primitive_types_known {} { - foreach type {void character logical*1 integer*1 integer*2 integer*8 \ - logical*2 logical*8 integer logical*4 real \ - real*8 real*16 complex*4 complex*8 complex*16} { - gdb_test "ptype $type" [string_to_regexp "type = $type"] + foreach type {void character \ + integer*1 integer*2 integer integer*8 \ + integer_1 integer_2 integer_8 \ + logical*1 logical*2 logical*4 logical*8 \ + logical_1 logical_2 logical_4 logical_8 \ + real real*8 real*16 real_8 real_16 \ + complex*4 complex*8 complex*16 \ + complex_4 complex_8 complex_16} { + + # While TYPE_KIND is allowed as input, GDB will always return the + # Fortran notation TYPE*KIND + regsub -all "_" $type "\*" type_res + gdb_test "ptype $type" [string_to_regexp "type = $type_res"] } } @@ -91,6 +113,7 @@ gdb_test "set print sevenbit-strings" "" if [set_lang_fortran] then { test_primitive_types_known + test_default_types test_integer_literal_types_accepted test_integer_literal_types_rejected test_logical_literal_types_accepted |