summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/recursive_check_4.f03
blob: d33e53555ca192fca8ecf4c0edeb5e113335a728 (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
33
34
35
36
! { dg-do compile }

! PR fortran/37779
! Check that using a non-recursive procedure as "value" is an error.

MODULE m
  IMPLICIT NONE

CONTAINS

  SUBROUTINE test ()
    IMPLICIT NONE
    PROCEDURE(test), POINTER :: procptr

    CALL bar (test) ! { dg-warning "Non-RECURSIVE" }
    procptr => test ! { dg-warning "Non-RECURSIVE" }
  END SUBROUTINE test

  INTEGER FUNCTION test2 () RESULT (x)
    IMPLICIT NONE
    PROCEDURE(test2), POINTER :: procptr

    CALL bar (test2) ! { dg-warning "Non-RECURSIVE" }
    procptr => test2 ! { dg-warning "Non-RECURSIVE" }

    x = 1812
  END FUNCTION test2

  INTEGER FUNCTION func ()
    ! Using a result variable is ok of course!
    func = 42 ! { dg-bogus "Non-RECURSIVE" }
  END FUNCTION func

END MODULE m

! { dg-final { cleanup-modules "m" } }