c: Fix up pointer types to may_alias structures [PR114493]
[official-gcc.git] / gcc / testsuite / gfortran.dg / allocatable_function_11.f90
blob1a2831e186f5b74617d7595376d7bc67ad170a4e
1 ! { dg-do compile }
2 ! PR fortran/109500 - check F2018:8.5.3 Note 1
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.
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" }
22 contains
23 subroutine s(p)
24 integer, allocatable :: p
25 end subroutine s
27 function f()
28 integer, allocatable :: f
29 allocate (f, source=42)
30 end function
32 logical function is_allocated(p)
33 integer, allocatable :: p
34 is_allocated = allocated(p)
35 end function
36 end program