aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/proc_ptr_comp_39.f90
blob: 8294ddcc1bfcbf869c4a72c1d7b4ceb583fdf96b (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
28
29
30
31
32
! { dg-do compile }
!
! PR 63674: [F03] procedure pointer and non/pure procedure
!
! Contributed by Valery Weber <valeryweber@hotmail.com>

program prog
  interface
    integer function nf()
    end function
    pure integer function pf()
    end function
    subroutine ns()
    end subroutine
    pure subroutine ps()
    end subroutine
  end interface
  type :: t
    procedure(nf), nopass, pointer :: nf => NULL()  ! non-pure function
    procedure(pf), nopass, pointer :: pf => NULL()  ! pure function
    procedure(ns), nopass, pointer :: ns => NULL()  ! non-pure subroutine
    procedure(ps), nopass, pointer :: ps => NULL()  ! pure subroutine
  end type
contains
  pure integer function eval(a)
    type(t), intent(in) :: a
    eval = a%pf()
    eval = a%nf()   ! { dg-error "Reference to impure function" }
    call a%ps()
    call a%ns()     ! { dg-error "is not PURE" }
  end function
end