| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Test the fix for PR84674, in which the non-overridable variant of the |
| 4 |
! procedure ff below caused a runtime segfault. |
| 5 |
! |
| 6 |
! Contributed by Jakub Benda <[email protected]> |
| 7 |
! |
| 8 |
module m |
| 9 |
implicit none |
| 10 |
|
| 11 |
type, abstract :: t1 |
| 12 |
integer :: i |
| 13 |
contains |
| 14 |
procedure(i_f), pass(u), deferred :: ff |
| 15 |
end type t1 |
| 16 |
|
| 17 |
type, abstract, extends(t1) :: t2 |
| 18 |
contains |
| 19 |
procedure, non_overridable, pass(u) :: ff => f ! Segmentation fault |
| 20 |
!procedure, pass(u) :: ff => f ! worked |
| 21 |
end type t2 |
| 22 |
|
| 23 |
type, extends(t2) :: DerivedType |
| 24 |
end type DerivedType |
| 25 |
|
| 26 |
abstract interface |
| 27 |
subroutine i_f(u) |
| 28 |
import :: t1 |
| 29 |
class(t1), intent(inout) :: u |
| 30 |
end subroutine i_f |
| 31 |
end interface |
| 32 |
|
| 33 |
contains |
| 34 |
|
| 35 |
subroutine f(u) |
| 36 |
class(t2), intent(inout) :: u |
| 37 |
u%i = 3*u%i |
| 38 |
end subroutine f |
| 39 |
|
| 40 |
end module m |
| 41 |
|
| 42 |
|
| 43 |
program p |
| 44 |
|
| 45 |
use m |
| 46 |
|
| 47 |
implicit none |
| 48 |
|
| 49 |
class(t1), allocatable :: v |
| 50 |
|
| 51 |
allocate(DerivedType::v) |
| 52 |
v%i = 2 |
| 53 |
call v%ff() |
| 54 |
if (v%i /= 6) stop |
| 55 |
end program p |