summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg
diff options
context:
space:
mode:
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2009-02-26 18:43:50 +0000
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2009-02-26 18:43:50 +0000
commitdd9670112ee3485a64802def2d5a0c88249b16e4 (patch)
treed310ef8eaa5e71425a136cec8058b82462b5febc /gcc/testsuite/gfortran.dg
parent7942cd01ed6f753635adc40b89639111176c6bc2 (diff)
downloadgcc-dd9670112ee3485a64802def2d5a0c88249b16e4.tar.gz
2009-02-26 Paul Thomas <pault@gcc.gnu.org>
PR fortran/39295 * interface.c (compare_type_rank_if): Return 1 if the symbols are the same and deal with external procedures where one is identified to be a function or subroutine by usage but the other is not. 2009-02-26 Paul Thomas <pault@gcc.gnu.org> PR fortran/39295 * gfortran.dg/interface_25.f90: New test. * gfortran.dg/interface_26.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144449 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
-rw-r--r--gcc/testsuite/gfortran.dg/interface_25.f9045
-rw-r--r--gcc/testsuite/gfortran.dg/interface_26.f9046
2 files changed, 91 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/interface_25.f90 b/gcc/testsuite/gfortran.dg/interface_25.f90
new file mode 100644
index 00000000000..0118cd563c7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/interface_25.f90
@@ -0,0 +1,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
diff --git a/gcc/testsuite/gfortran.dg/interface_26.f90 b/gcc/testsuite/gfortran.dg/interface_26.f90
new file mode 100644
index 00000000000..9f7fa4ef3f6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/interface_26.f90
@@ -0,0 +1,46 @@
+! { dg-do compile }
+! Tests the fix for PR39295, in which the check of the interfaces
+! at lines 26 and 43 failed because opfunc1 is identified as a
+! function by usage, whereas opfunc2 is not. This testcase checks
+! that TKR is stll OK in these cases.
+!
+! 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 ) ! { dg-error "Type/rank mismatch in argument" }
+ 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
+ REAL, 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