| 1 |
!{ dg-do run } |
| 2 |
|
| 3 |
! Check that PR119272 is fixed |
| 4 |
! Contributed by Xing Jing Wei <[email protected]> |
| 5 |
|
| 6 |
module pr119272_module |
| 7 |
type, public :: test_type |
| 8 |
contains |
| 9 |
procedure :: scal_function |
| 10 |
procedure :: arr_function |
| 11 |
end type test_type |
| 12 |
contains |
| 13 |
function scal_function(this) result(smth) |
| 14 |
class(test_type) :: this |
| 15 |
integer :: smth |
| 16 |
smth = 2 |
| 17 |
end function |
| 18 |
function arr_function(this) result(smth) |
| 19 |
class(test_type) :: this |
| 20 |
integer :: smth(9) |
| 21 |
smth = (/(i, i=1, 9)/) |
| 22 |
end function |
| 23 |
end module |
| 24 |
|
| 25 |
program pr119272 |
| 26 |
use pr119272_module |
| 27 |
implicit none |
| 28 |
|
| 29 |
type(test_type) :: a |
| 30 |
|
| 31 |
call test_subroutine(a) |
| 32 |
contains |
| 33 |
subroutine test_subroutine(a) |
| 34 |
class(test_type) :: a |
| 35 |
integer :: i |
| 36 |
integer,parameter :: temp_int(3) = [ 1, 2, 3] |
| 37 |
integer,parameter :: identity(9) = (/(i* 5, i= 9, 1, -1)/) |
| 38 |
associate(temp => temp_int(a%scal_function())) |
| 39 |
if (temp /= 2) stop 1 |
| 40 |
end associate |
| 41 |
|
| 42 |
associate(temparr => identity(a%arr_function())) |
| 43 |
if (any(temparr /= (/(i* 5, i= 9, 1, -1)/))) stop 2 |
| 44 |
end associate |
| 45 |
end subroutine |
| 46 |
end program |
| 47 |
|