aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-lang.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-01-07 17:13:21 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-01-08 09:54:21 +0000
commite343681375c1e5a27ea92486649f6a58163c0e61 (patch)
tree47d8e5fea92b292b5a90b80be8bbc08cf2106add /gdb/f-lang.c
parentf4cfa91741b71bc4b64c6e8ec132873d6d5f7957 (diff)
downloadgdb-e343681375c1e5a27ea92486649f6a58163c0e61.zip
gdb-e343681375c1e5a27ea92486649f6a58163c0e61.tar.gz
gdb-e343681375c1e5a27ea92486649f6a58163c0e61.tar.bz2
gdb/fortran: Correct the lval type for array elements of internal vars
Since this commit: commit a5c641b57b0b5e245b8a011cccc93a4120c8bd63 Date: Thu Oct 8 16:45:59 2020 +0100 gdb/fortran: Add support for Fortran array slices at the GDB prompt A bug was introduced into GDB. Consider this Fortan array: integer, dimension (1:10) :: array array = 1 Now inside GDB: (gdb) set $var = array (gdb) set $var(1) = 2 Left operand of assignment is not an lvalue. The problem is that the new code for slicing Fortran arrays now does not set the lval type correctly for arrays that are not in memory. This is easily fixed by making use of value_from_component. After this the above example behaves as you'd expect. gdb/ChangeLog: * f-lang.c (fortran_value_subarray): Call value_from_component. gdb/testsuite/ChangeLog: * gdb.fortran/intvar-array.exp: New file. * gdb.fortran/intvar-array.f90: New file.
Diffstat (limited to 'gdb/f-lang.c')
-rw-r--r--gdb/f-lang.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index da66ba8..8329109 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -690,11 +690,7 @@ fortran_value_subarray (struct value *array, struct expression *exp,
+ total_offset));
}
else if (!value_lazy (array))
- {
- const void *valaddr = value_contents (array) + total_offset;
- array = allocate_value (array_slice_type);
- memcpy (value_contents_raw (array), valaddr, TYPE_LENGTH (array_slice_type));
- }
+ array = value_from_component (array, array_slice_type, total_offset);
else
error (_("cannot subscript arrays that are not in memory"));
}