summaryrefslogtreecommitdiff
path: root/gdb/f-exp.y
diff options
context:
space:
mode:
authorNils-Christian Kempke <nils-christian.kempke@intel.com>2022-04-11 14:06:56 +0200
committerNils-Christian Kempke <nils-christian.kempke@intel.com>2022-04-11 14:06:56 +0200
commitadc29023a741fbeb23dc3e07a0328cca4e9061f1 (patch)
treec0d986d6c03c24859ef2569bf163680ec40f3418 /gdb/f-exp.y
parent4ec8aa9e94858144a4ca831ae810d741a172d4b7 (diff)
downloadbinutils-gdb-adc29023a741fbeb23dc3e07a0328cca4e9061f1.tar.gz
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/f-exp.y')
-rw-r--r--gdb/f-exp.y50
1 files changed, 33 insertions, 17 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index a768134983b..bb8e2ba6475 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -167,11 +167,12 @@ static int parse_number (struct parser_state *, const char *, int,
/* Special type cases, put in to allow the parser to distinguish different
legal basetypes. */
-%token INT_KEYWORD INT_S2_KEYWORD LOGICAL_S1_KEYWORD LOGICAL_S2_KEYWORD
+%token INT_S1_KEYWORD INT_S2_KEYWORD INT_KEYWORD INT_S4_KEYWORD INT_S8_KEYWORD
+%token LOGICAL_S1_KEYWORD LOGICAL_S2_KEYWORD LOGICAL_KEYWORD LOGICAL_S4_KEYWORD
%token LOGICAL_S8_KEYWORD
-%token LOGICAL_KEYWORD REAL_KEYWORD REAL_S8_KEYWORD REAL_S16_KEYWORD
-%token COMPLEX_KEYWORD
-%token COMPLEX_S4_KEYWORD COMPLEX_S8_KEYWORD COMPLEX_S16_KEYWORD
+%token REAL_KEYWORD REAL_S4_KEYWORD REAL_S8_KEYWORD REAL_S16_KEYWORD
+%token COMPLEX_KEYWORD COMPLEX_S4_KEYWORD COMPLEX_S8_KEYWORD
+%token COMPLEX_S16_KEYWORD
%token BOOL_AND BOOL_OR BOOL_NOT
%token SINGLE DOUBLE PRECISION
%token <lval> CHARACTER
@@ -757,22 +758,32 @@ func_mod: '(' ')'
typebase /* Implements (approximately): (type-qualifier)* type-specifier */
: TYPENAME
{ $$ = $1.type; }
+ | INT_S1_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_integer_s1; }
+ | INT_S2_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_integer_s2; }
| INT_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_integer; }
- | INT_S2_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_integer_s2; }
+ | INT_S4_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_integer; }
+ | INT_S8_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_integer_s8; }
| CHARACTER
{ $$ = parse_f_type (pstate)->builtin_character; }
- | LOGICAL_S8_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_logical_s8; }
- | LOGICAL_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_logical; }
- | LOGICAL_S2_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_logical_s2; }
| LOGICAL_S1_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_logical_s1; }
+ | LOGICAL_S2_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_logical_s2; }
+ | LOGICAL_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_logical; }
+ | LOGICAL_S4_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_logical; }
+ | LOGICAL_S8_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_logical_s8; }
| REAL_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_real; }
+ | REAL_S4_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_real; }
| REAL_S8_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_real_s8; }
| REAL_S16_KEYWORD
@@ -1130,21 +1141,26 @@ static const struct f77_boolean_val boolean_values[] =
static const struct token f77_keywords[] =
{
/* Historically these have always been lowercase only in GDB. */
+ { "character", CHARACTER, OP_NULL, true },
{ "complex", COMPLEX_KEYWORD, OP_NULL, true },
{ "complex_4", COMPLEX_S4_KEYWORD, OP_NULL, true },
{ "complex_8", COMPLEX_S8_KEYWORD, OP_NULL, true },
{ "complex_16", COMPLEX_S16_KEYWORD, OP_NULL, true },
- { "character", CHARACTER, OP_NULL, true },
+ { "integer_1", INT_S1_KEYWORD, OP_NULL, true },
{ "integer_2", INT_S2_KEYWORD, OP_NULL, true },
+ { "integer_4", INT_S4_KEYWORD, OP_NULL, true },
+ { "integer", INT_KEYWORD, OP_NULL, true },
+ { "integer_8", INT_S8_KEYWORD, OP_NULL, true },
{ "logical_1", LOGICAL_S1_KEYWORD, OP_NULL, true },
{ "logical_2", LOGICAL_S2_KEYWORD, OP_NULL, true },
- { "logical_8", LOGICAL_S8_KEYWORD, OP_NULL, true },
- { "integer", INT_KEYWORD, OP_NULL, true },
{ "logical", LOGICAL_KEYWORD, OP_NULL, true },
+ { "logical_4", LOGICAL_S4_KEYWORD, OP_NULL, true },
+ { "logical_8", LOGICAL_S8_KEYWORD, OP_NULL, true },
+ { "real", REAL_KEYWORD, OP_NULL, true },
+ { "real_4", REAL_S4_KEYWORD, OP_NULL, true },
+ { "real_8", REAL_S8_KEYWORD, OP_NULL, true },
{ "real_16", REAL_S16_KEYWORD, OP_NULL, true },
{ "sizeof", SIZEOF, OP_NULL, true },
- { "real_8", REAL_S8_KEYWORD, OP_NULL, true },
- { "real", REAL_KEYWORD, OP_NULL, true },
{ "single", SINGLE, OP_NULL, true },
{ "double", DOUBLE, OP_NULL, true },
{ "precision", PRECISION, OP_NULL, true },