From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4DE7E3861925; Tue, 11 Aug 2020 11:27:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DE7E3861925 From: "antonio.mccarneiro at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug fortran/26373] New: Printing members of parent type from an instance of an extended type Date: Tue, 11 Aug 2020 11:27:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: fortran X-Bugzilla-Version: 9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: antonio.mccarneiro at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2020 11:27:54 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26373 Bug ID: 26373 Summary: Printing members of parent type from an instance of an extended type Product: gdb Version: 9.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: fortran Assignee: unassigned at sourceware dot org Reporter: antonio.mccarneiro at gmail dot com Target Milestone: --- * Scenario (see the code below): consider some Fortran module my_module whi= ch contains the definition of two derived types: test (parent) and sub_test (extends test, subclass). In addition to the two members a and b of the par= ent class, sub_test defines a new member c. Eventually, this module my_module i= s to used in some program my_program. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D module my_module implicit none private public :: test, sub_test type :: test integer :: a =3D 1 integer :: b =3D 2 end type test type, extends(test) :: sub_test integer :: c =3D 3 contains procedure, public :: increment end type sub_test contains subroutine increment (this) class(sub_test) :: this this % a =3D this % a + 1 write(*, *) "Incrementation complete!" end subroutine increment end module my_module !--------------------------------------- program my_program use my_module implicit none type(test) :: parent type(sub_test) :: child write(*, *) "Printing parent members" write(*, *) parent % a, parent % b write(*, *) "Printing child members" write(*, *) child % a, child % b, child % c call child % increment end program my_program =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D * Objective: When debugging, using gdb, we want to print the values of the parent members a and b of some variable of the child (extended) type sub_te= st. In sum, we're looking for a successful completion of something like: ---------------------- (gdb) print child % a ---------------------- yet, apparently, it is not that trivial. What I have (unsuccessfully) tried so far: 1. Print directly the members from the child variable (member c prints flawlessly) ------------------------------------------------ Breakpoint 1, my_program () at test.f90:41 41 write(*, *) child % a, child % b, child % c (gdb) p child%a There is no member named a. (gdb) p child%b There is no member named b. (gdb) p child%c $1 =3D 3 ------------------------------------------------ 2. Print the test (parent) member of the child variable, as gdb shows it exists 3. Print the so-wanted members from the test member of child ------------------------------------------------ Breakpoint 1, my_program () at test.f90:41 41 write(*, *) child % a, child % b, child % c (gdb) p child $2 =3D ( test =3D ( a =3D 1, b =3D 2 ), c =3D 3 ) (gdb) p child%test A syntax error in expression, near `test'. (gdb) p child%test%a A syntax error in expression, near `test%a'. (gdb) p child%test%b A syntax error in expression, near `test%b'. ------------------------------------------------ More information: I am using gdb-9.2 and gfortran 7.5.0. --=20 You are receiving this mail because: You are on the CC list for the bug.=