summaryrefslogtreecommitdiff
path: root/gdb/f-exp.y
diff options
context:
space:
mode:
authorBernhard Heckel <bernhard.heckel@intel.com>2022-04-05 17:44:46 +0200
committerNils-Christian Kempke <nils-christian.kempke@intel.com>2022-04-08 12:17:13 +0200
commit87e10e9c288c2f6c933f235b623522c8d9a2d727 (patch)
tree5501d64f3c0e33b7079ed2f92bf0e65000ffbe02 /gdb/f-exp.y
parent916c9be4a31d91ee0ebbb33efbf87a8e3cf13349 (diff)
downloadbinutils-gdb-87e10e9c288c2f6c933f235b623522c8d9a2d727.tar.gz
gdb/fortran: add support for accessing fields of extended types
Fortran 2003 supports type extension. This patch allows access to inherited members by using their fully qualified name as described in the Fortran standard. In doing so the patch also fixes a bug in GDB when trying to access the members of a base class in a derived class via the derived class' base class member. This patch fixes PR22497 and PR26373 on GDB side. Using the example Fortran program from PR22497 program mvce implicit none type :: my_type integer :: my_int end type my_type type, extends(my_type) :: extended_type end type extended_type type(my_type) :: foo type(extended_type) :: bar foo%my_int = 0 bar%my_int = 1 print*, foo, bar end program mvce and running this with GDB and setting a BP at 17: Before: (gdb) p bar%my_type A syntax error in expression, near `my_type'. (gdb) p bar%my_int There is no member named my_int. (gdb) p bar%my_type%my_int A syntax error in expression, near `my_type%my_int'. (gdb) p bar $1 = ( my_type = ( my_int = 1 ) ) After: (gdb) p bar%my_type $1 = ( my_int = 1 ) (gdb) p bar%my_int $2 = 1 # this line requires DW_TAG_inheritance to work (gdb) p bar%my_type%my_int $3 = 1 (gdb) p bar $4 = ( my_type = ( my_int = 1 ) ) In the above example "p bar%my_int" requires the compiler to emit information about the inheritance relationship between extended_type and my_type which gfortran and flang currently do not de. The respective issue gcc/49475 has been put as kfail. Co-authored-by: Nils-Christian Kempke <nils-christian.kempke@intel.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26373 https://sourceware.org/bugzilla/show_bug.cgi?id=22497
Diffstat (limited to 'gdb/f-exp.y')
-rw-r--r--gdb/f-exp.y7
1 files changed, 5 insertions, 2 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 9cba30f6837..f9622e63fb2 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -808,8 +808,11 @@ nonempty_typelist
}
;
-name : NAME
- { $$ = $1.stoken; }
+name
+ : NAME
+ { $$ = $1.stoken; }
+ | TYPENAME
+ { $$ = $1.stoken; }
;
name_not_typename : NAME