| 1 |
! { dg-do compile } |
| 2 |
! PR fortran/109500 - check F2018:8.5.3 Note 1 |
| 3 |
! |
| 4 |
! The result of referencing a function whose result variable has the |
| 5 |
! ALLOCATABLE attribute is a value that does not itself have the |
| 6 |
! ALLOCATABLE attribute. |
| 7 |
|
| 8 |
program main |
| 9 |
implicit none |
| 10 |
integer, allocatable :: p |
| 11 |
procedure(f), pointer :: pp |
| 12 |
pp => f |
| 13 |
p = f() |
| 14 |
print *, allocated (p) |
| 15 |
print *, is_allocated (p) |
| 16 |
print *, is_allocated (f()) ! { dg-error "is a function result" } |
| 17 |
print *, is_allocated (pp()) ! { dg-error "is a function result" } |
| 18 |
call s (p) |
| 19 |
call s (f()) ! { dg-error "is a function result" } |
| 20 |
call s (pp()) ! { dg-error "is a function result" } |
| 21 |
|
| 22 |
contains |
| 23 |
subroutine s(p) |
| 24 |
integer, allocatable :: p |
| 25 |
end subroutine s |
| 26 |
|
| 27 |
function f() |
| 28 |
integer, allocatable :: f |
| 29 |
allocate (f, source=42) |
| 30 |
end function |
| 31 |
|
| 32 |
logical function is_allocated(p) |
| 33 |
integer, allocatable :: p |
| 34 |
is_allocated = allocated(p) |
| 35 |
end function |
| 36 |
end program |