aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/ptr_func_assign_4.f08
blob: 46ef2ac556689ef5cb45af80da3fb0557f55fec9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
! { dg-do compile }
!
! Tests correction to implementation of pointer function assignments.
!
! Contributed by Mikael Morin  <mikael.morin@sfr.fr>
!
program p
  integer, target :: a(3) = 2
  integer :: b(3, 3) = 1
  integer :: c

  c = 3
  func (b(2, 2)) = b ! { dg-error "Different ranks" }
  func (c) = b       ! { dg-error "Different ranks" }

contains
  function func(arg) result(r)
    integer, pointer :: r(:)
    integer :: arg

    if (arg == 1) then
      r => a
    else
      r => null()
    end if
  end function func
end program p