diff options
author | Tom de Vries <tdevries@suse.de> | 2024-07-31 13:11:48 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-07-31 13:11:48 +0200 |
commit | 50fb268a6ff81c5a88119474ffe61cd4df1a8248 (patch) | |
tree | 5f66ad63b2c7c14ab62f175bc3ce2338316fd1ba /gdb/f-exp.y | |
parent | c39fbc749a545ac2b728173a340095b614585c96 (diff) | |
download | binutils-50fb268a6ff81c5a88119474ffe61cd4df1a8248.zip binutils-50fb268a6ff81c5a88119474ffe61cd4df1a8248.tar.gz binutils-50fb268a6ff81c5a88119474ffe61cd4df1a8248.tar.bz2 |
[gdb/exp] Fix gdb.fortran/intrinsics.exp fail on arm
When running test-case gdb.fortran/intrinsics.exp on arm-linux, I get:
...
(gdb) p cmplx (4,4,16)^M
/home/linux/gdb/src/gdb/f-lang.c:1002: internal-error: eval_op_f_cmplx: \
Assertion `kind_arg->code () == TYPE_CODE_COMPLEX' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
----- Backtrace -----^M
FAIL: gdb.fortran/intrinsics.exp: p cmplx (4,4,16) (GDB internal error)
...
The problem is that 16-byte floats are unsupported:
...
$ gfortran test.f90
test.f90:2:17:
2 | REAL(kind=16) :: foo = 1
| 1
Error: Kind 16 not supported for type REAL at (1)
...
and consequently we end up with a builtin_real_s16 and builtin_complex_s16 with
code TYPE_CODE_ERROR.
Fix this by bailing out asap when encountering such a type.
Without this patch we're able to do the rather useless:
...
(gdb) ptype real*16
type = real*16
(gdb) ptype real_16
type = real*16
...
but with this patch we get:
...
(gdb) ptype real*16
unsupported kind 16 for type real*4
(gdb) ptype real_16
unsupported type real*16
...
Tested on arm-linux.
PR fortran/30537
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30537
Diffstat (limited to 'gdb/f-exp.y')
-rw-r--r-- | gdb/f-exp.y | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y index bdf9c32..259f274 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -754,7 +754,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ | REAL_S8_KEYWORD { $$ = parse_f_type (pstate)->builtin_real_s8; } | REAL_S16_KEYWORD - { $$ = parse_f_type (pstate)->builtin_real_s16; } + { $$ = parse_f_type (pstate)->builtin_real_s16; + if ($$->code () == TYPE_CODE_ERROR) + error (_("unsupported type %s"), + TYPE_SAFE_NAME ($$)); + } | COMPLEX_KEYWORD { $$ = parse_f_type (pstate)->builtin_complex; } | COMPLEX_S4_KEYWORD @@ -762,7 +766,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ | COMPLEX_S8_KEYWORD { $$ = parse_f_type (pstate)->builtin_complex_s8; } | COMPLEX_S16_KEYWORD - { $$ = parse_f_type (pstate)->builtin_complex_s16; } + { $$ = parse_f_type (pstate)->builtin_complex_s16; + if ($$->code () == TYPE_CODE_ERROR) + error (_("unsupported type %s"), + TYPE_SAFE_NAME ($$)); + } | SINGLE PRECISION { $$ = parse_f_type (pstate)->builtin_real;} | DOUBLE PRECISION @@ -1156,12 +1164,9 @@ push_kind_type (LONGEST val, struct type *type) type_stack->push (tp_kind); } -/* Called when a type has a '(kind=N)' modifier after it, for example - 'character(kind=1)'. The BASETYPE is the type described by 'character' - in our example, and KIND is the integer '1'. This function returns a - new type that represents the basetype of a specific kind. */ +/* Helper function for convert_to_kind_type. */ static struct type * -convert_to_kind_type (struct type *basetype, int kind) +convert_to_kind_type_1 (struct type *basetype, int kind) { if (basetype == parse_f_type (pstate)->builtin_character) { @@ -1211,13 +1216,25 @@ convert_to_kind_type (struct type *basetype, int kind) return parse_f_type (pstate)->builtin_integer_s8; } - error (_("unsupported kind %d for type %s"), - kind, TYPE_SAFE_NAME (basetype)); - - /* Should never get here. */ return nullptr; } +/* Called when a type has a '(kind=N)' modifier after it, for example + 'character(kind=1)'. The BASETYPE is the type described by 'character' + in our example, and KIND is the integer '1'. This function returns a + new type that represents the basetype of a specific kind. */ +static struct type * +convert_to_kind_type (struct type *basetype, int kind) +{ + struct type *res = convert_to_kind_type_1 (basetype, kind); + + if (res == nullptr || res->code () == TYPE_CODE_ERROR) + error (_("unsupported kind %d for type %s"), + kind, TYPE_SAFE_NAME (basetype)); + + return res; +} + struct f_token { /* The string to match against. */ |