aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/interface_25.f90
blob: 0118cd563c7377bc435858c6c23df79702a2e286 (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
37
38
39
40
41
42
43
44
45
! { dg-do compile }
! Tests the fix for PR39295, in which the check of the interfaces
! at lines 25 and 42 failed because opfunc1 is identified as a 
! function by usage, whereas opfunc2 is not.
!
! Contributed by Jon Hurst <jhurst@ucar.edu>
!
MODULE  funcs
CONTAINS
  INTEGER FUNCTION test1(a,b,opfunc1) 
    INTEGER :: a,b
    INTEGER, EXTERNAL :: opfunc1
    test1 = opfunc1( a, b ) 
  END FUNCTION test1
  INTEGER FUNCTION sumInts(a,b)
    INTEGER :: a,b
    sumInts = a + b
  END FUNCTION sumInts
END MODULE funcs

PROGRAM test
  USE funcs 
  INTEGER :: rs
  INTEGER, PARAMETER :: a = 2, b = 1
  rs = recSum( a, b, test1, sumInts )
  write(*,*) "Results", rs
CONTAINS
  RECURSIVE INTEGER FUNCTION recSum( a,b,UserFunction,UserOp ) RESULT( res )
    IMPLICIT NONE
    INTEGER :: a,b
    INTERFACE 
       INTEGER FUNCTION UserFunction(a,b,opfunc2) 
         INTEGER :: a,b
         INTEGER, EXTERNAL :: opfunc2
       END FUNCTION UserFunction
    END INTERFACE
    INTEGER, EXTERNAL :: UserOp 

    res = UserFunction( a,b, UserOp )

    if( res .lt. 10 ) then
       res = recSum( a, res, UserFunction, UserOp ) 
    end if
  END FUNCTION recSum
END PROGRAM test