| 1 |
! { dg-do run } |
| 2 |
! PR fortran/100551 - Passing return value to class(*) dummy argument |
| 3 |
|
| 4 |
program p |
| 5 |
implicit none |
| 6 |
integer :: result |
| 7 |
result = 1 |
| 8 |
result = test ( (result)) ! works |
| 9 |
if (result /= 1) stop 1 |
| 10 |
result = test (int (result)) ! issue 1 |
| 11 |
! write(*,*) result |
| 12 |
if (result /= 1) stop 2 |
| 13 |
result = test (f (result)) ! issue 2 |
| 14 |
! write(*,*) result |
| 15 |
if (result /= 2) stop 3 |
| 16 |
contains |
| 17 |
integer function test(x) |
| 18 |
class(*), intent(in) :: x |
| 19 |
select type (x) |
| 20 |
type is (integer) |
| 21 |
test = x |
| 22 |
class default |
| 23 |
test = -1 |
| 24 |
end select |
| 25 |
end function test |
| 26 |
integer function f(x) |
| 27 |
integer, intent(in) :: x |
| 28 |
f = 2*x |
| 29 |
end function f |
| 30 |
end program |