diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-07-09 16:26:23 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-07-25 01:30:20 +0100 |
commit | e79eb02f2f09baecffb144bac6804f975065466f (patch) | |
tree | e1a92e0b6eb55bb577cb18a2caafab54685ab8d8 /gdb/value.h | |
parent | 719251fee155d5d4ede91f555e8898460e6b1731 (diff) | |
download | gdb-e79eb02f2f09baecffb144bac6804f975065466f.zip gdb-e79eb02f2f09baecffb144bac6804f975065466f.tar.gz gdb-e79eb02f2f09baecffb144bac6804f975065466f.tar.bz2 |
gdb/fortran: resolve dynamic types when readjusting after an indirection
After dereferencing a pointer (in value_ind) or following a
reference (in coerce_ref) we call readjust_indirect_value_type to
"fixup" the type of the resulting value object.
This fixup handles cases relating to the type of the resulting object
being different (a sub-class) of the original pointers target type.
If we encounter a pointer to a dynamic type then after dereferencing a
pointer (in value_ind) the type of the object created will have had
its dynamic type resolved. However, in readjust_indirect_value_type,
we use the target type of the original pointer to "fixup" the type of
the resulting value. In this case, the target type will be a dynamic
type, so the resulting value object, once again has a dynamic type.
This then triggers an assertion later within GDB.
The solution I propose here is that we call resolve_dynamic_type on
the pointer's target type (within readjust_indirect_value_type) so
that the resulting value is not converted back to a dynamic type.
The test case is based on the original test in the bug report.
gdb/ChangeLog:
PR fortran/23051
PR fortran/26139
* valops.c (value_ind): Pass address to
readjust_indirect_value_type.
* value.c (readjust_indirect_value_type): Make parameter
non-const, and add extra address parameter. Resolve original type
before using it.
* value.h (readjust_indirect_value_type): Update function
signature and comment.
gdb/testsuite/ChangeLog:
PR fortran/23051
PR fortran/26139
* gdb.fortran/class-allocatable-array.exp: New file.
* gdb.fortran/class-allocatable-array.f90: New file.
* gdb.fortran/pointer-to-pointer.exp: New file.
* gdb.fortran/pointer-to-pointer.f90: New file.
Diffstat (limited to 'gdb/value.h')
-rw-r--r-- | gdb/value.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gdb/value.h b/gdb/value.h index 70c3d56..12e4a13 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -488,7 +488,9 @@ extern struct value *coerce_ref_if_computed (const struct value *arg); /* Setup a new value type and enclosing value type for dereferenced value VALUE. ENC_TYPE is the new enclosing type that should be set. ORIGINAL_TYPE and - ORIGINAL_VAL are the type and value of the original reference or pointer. + ORIGINAL_VAL are the type and value of the original reference or + pointer. ORIGINAL_VALUE_ADDRESS is the address within VALUE, that is + the address that was dereferenced. Note, that VALUE is modified by this function. @@ -497,7 +499,8 @@ extern struct value *coerce_ref_if_computed (const struct value *arg); extern struct value * readjust_indirect_value_type (struct value *value, struct type *enc_type, const struct type *original_type, - const struct value *original_val); + struct value *original_val, + CORE_ADDR original_value_address); /* Convert a REF to the object referenced. */ |