aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-exp.y
diff options
context:
space:
mode:
authorNils-Christian Kempke <nils-christian.kempke@intel.com>2022-04-11 14:06:55 +0200
committerNils-Christian Kempke <nils-christian.kempke@intel.com>2022-04-11 14:06:55 +0200
commit4e436fdabe216b5684b4efb6978843b2380fe32a (patch)
treefab532fa29c1587a0c280189d377f0b8ed333055 /gdb/f-exp.y
parentc08ec64081d95b7a9abf35e54efaf44051aea195 (diff)
downloadgdb-4e436fdabe216b5684b4efb6978843b2380fe32a.zip
gdb-4e436fdabe216b5684b4efb6978843b2380fe32a.tar.gz
gdb-4e436fdabe216b5684b4efb6978843b2380fe32a.tar.bz2
gdb/fortran: fix complex type in Fortran builtin types
Before this patch things like (gdb) ptype complex*8 complex*16 (gdb) ptype complex*4 complex*8 were possible in GDB, which seems confusing for a user. The reason is a mixup in the implementation of the Fortran COMPLEX type. In Fortran the "*X" after a type would normally (I don't think this is language required) specify the type's size in memory. For the COMPLEX type the kind parameters usually (at least for GNU, Intel, Flang) specify not the size of the whole type but the size of the individual two REALs used to form the COMPLEX. Thus, a COMPLEX*4 will usually consist of two REAL*4s. Internally this type was represented by a builtin_complex_s8 - but here I think the s8 actually meant the raw size of the type. This is confusing and I renamed the types (e.g. builting_complex_s8 became builtin_complex_s4 according to its most common useage) and their printed names to their language equivalent. Additionally, I added the default COMPLEX type "COMPLEX" being the same as a COMPLEX*4 (as is normally the case) and removed the latter. I added a few tests for this new behavior as well. The new behavior is (gdb) ptype complex*8 complex*8 (gdb) ptype complex*4 complex*4
Diffstat (limited to 'gdb/f-exp.y')
-rw-r--r--gdb/f-exp.y26
1 files changed, 13 insertions, 13 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index d6103a0..a768134 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -171,7 +171,7 @@ static int parse_number (struct parser_state *, const char *, int,
%token LOGICAL_S8_KEYWORD
%token LOGICAL_KEYWORD REAL_KEYWORD REAL_S8_KEYWORD REAL_S16_KEYWORD
%token COMPLEX_KEYWORD
-%token COMPLEX_S8_KEYWORD COMPLEX_S16_KEYWORD COMPLEX_S32_KEYWORD
+%token COMPLEX_S4_KEYWORD COMPLEX_S8_KEYWORD COMPLEX_S16_KEYWORD
%token BOOL_AND BOOL_OR BOOL_NOT
%token SINGLE DOUBLE PRECISION
%token <lval> CHARACTER
@@ -778,21 +778,21 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
| REAL_S16_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_real_s16; }
| COMPLEX_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_complex_s8; }
+ { $$ = parse_f_type (pstate)->builtin_complex; }
+ | COMPLEX_S4_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_complex; }
| COMPLEX_S8_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_complex_s8; }
| COMPLEX_S16_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_complex_s16; }
- | COMPLEX_S32_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_complex_s32; }
| SINGLE PRECISION
{ $$ = parse_f_type (pstate)->builtin_real;}
| DOUBLE PRECISION
{ $$ = parse_f_type (pstate)->builtin_real_s8;}
| SINGLE COMPLEX_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_complex_s8;}
+ { $$ = parse_f_type (pstate)->builtin_complex;}
| DOUBLE COMPLEX_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_complex_s16;}
+ { $$ = parse_f_type (pstate)->builtin_complex_s8;}
;
nonempty_typelist
@@ -1020,14 +1020,14 @@ convert_to_kind_type (struct type *basetype, int kind)
if (kind == 1)
return parse_f_type (pstate)->builtin_character;
}
- else if (basetype == parse_f_type (pstate)->builtin_complex_s8)
+ else if (basetype == parse_f_type (pstate)->builtin_complex)
{
if (kind == 4)
- return parse_f_type (pstate)->builtin_complex_s8;
+ return parse_f_type (pstate)->builtin_complex;
else if (kind == 8)
- return parse_f_type (pstate)->builtin_complex_s16;
+ return parse_f_type (pstate)->builtin_complex_s8;
else if (kind == 16)
- return parse_f_type (pstate)->builtin_complex_s32;
+ return parse_f_type (pstate)->builtin_complex_s16;
}
else if (basetype == parse_f_type (pstate)->builtin_real)
{
@@ -1130,18 +1130,18 @@ static const struct f77_boolean_val boolean_values[] =
static const struct token f77_keywords[] =
{
/* Historically these have always been lowercase only in GDB. */
+ { "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 },
- { "complex_32", COMPLEX_S32_KEYWORD, OP_NULL, true },
{ "character", CHARACTER, OP_NULL, true },
{ "integer_2", INT_S2_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 },
- { "complex_8", COMPLEX_S8_KEYWORD, OP_NULL, true },
{ "integer", INT_KEYWORD, OP_NULL, true },
{ "logical", LOGICAL_KEYWORD, OP_NULL, true },
{ "real_16", REAL_S16_KEYWORD, OP_NULL, true },
- { "complex", COMPLEX_KEYWORD, OP_NULL, true },
{ "sizeof", SIZEOF, OP_NULL, true },
{ "real_8", REAL_S8_KEYWORD, OP_NULL, true },
{ "real", REAL_KEYWORD, OP_NULL, true },