Debian Codegraph @

gcc/testsuite/gfortran.dg/pr117730_a.f90

raw
1 ! { dg-do compile }
2 !
3 ! Test the fix for PR117730 in which the non_overrridable procedures in 'child'
4 ! were mixied up in the vtable for the extension 'child2' in pr117730_b.f90.
5 ! This resulted in 'this%calc()' in 'function child_get(this)' returning garbage
6 ! when 'this' was of dynamic type 'child2'.
7 !
8 ! Contributed by <[email protected]> in comment 4 of PR84674.
9 !
10 module module1
11 implicit none
12 private
13 public :: child
14
15 type, abstract :: parent
16 contains
17 procedure, pass :: reset => parent_reset
18 end type parent
19
20 type, extends(parent), abstract :: child
21 contains
22 procedure, pass, non_overridable :: reset => child_reset
23 procedure, pass, non_overridable :: get => child_get
24 procedure(calc_i), pass, deferred :: calc
25 end type child
26
27 abstract interface
28 pure function calc_i(this) result(value)
29 import :: child
30 class(child), intent(in) :: this
31 integer :: value
32 end function calc_i
33 end interface
34
35 contains
36 pure subroutine parent_reset(this)
37 class(parent), intent(inout) :: this
38 end subroutine parent_reset
39
40 pure subroutine child_reset(this)
41 class(child), intent(inout) :: this
42 end subroutine child_reset
43
44 function child_get(this) result(value)
45 class(child), intent(inout) :: this
46 integer :: value
47
48 value = this%calc()
49 end function child_get
50 end module module1