This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [patch ping] Test gfortran -ff2c COMPLEX function return values
- From: "Billinghurst, David \(CALCRTS\)" <david dot billinghurst at comalco dot riotinto dot com dot au>
- To: <gcc-patches at gcc dot gnu dot org>
- Cc: <fortran at gcc dot gnu dot org>
- Date: Thu, 23 Jun 2005 13:01:39 +1000
- Subject: RE: [patch ping] Test gfortran -ff2c COMPLEX function return values
> From: Steven Bosscher
>
> On Jun 20, 2005 08:51 AM, "Billinghurst, David (CALCRTS)"
> <david.billinghurst@comalco.riotinto.com.au> wrote:
>
> > This tests gfortran calling conventions for complex functions
> > with -ff2c (or I could add this to existing test f2c_4.{f90,c})
> >
> > http://gcc.gnu.org/ml/gcc-patches/2005-06/msg00428.html
>
> Wow, nice. I hadn't notice this patch before. Go for it if
> this works,
> we should have more tests like this!
>
I ended up adding this to an existing case. This is what I committed.
2005-06-23 David Billinghurst <David.Billinghurst@riotinto.com>
* gfortran.dg/f2c_4.f90: Add tests for complex functions
* gfortran.dg/f2c_4.c: Likewise
RCS file: /cvs/gcc/gcc/gcc/testsuite/gfortran.dg/f2c_4.f90,v
retrieving revision 1.1
diff -u -r1.1 f2c_4.f90
--- f2c_4.f90 5 Jun 2005 23:42:19 -0000 1.1
+++ f2c_4.f90 23 Jun 2005 02:58:54 -0000
@@ -4,11 +4,55 @@
! Check -ff2c calling conventions
! Return value of REAL function is promoted to C type double
-! Addional underscore appended to function name
-call f2c_4a()
+! Return value of COMPLEX function is via an extra argument in the
+! calling sequence that points to where to store the return value
+! Addional underscore appended to function name
+program f2c_4
+ complex c, f2c_4k, f2c_4l
+ double complex z, f2c_4m, f2c_4n
+ integer i
+
+ ! Promotion of REAL function
+ call f2c_4a()
+
+ ! Return COMPLEX arg - call Fortran routines from C
+ call f2c_4c()
+ call f2c_4e()
+ call f2c_4g()
+ call f2c_4i()
+
+ ! Return COMPLEX arg - call C routines from Fortran
+ c = cmplx(1234.0,5678.0)
+ z = dcmplx(1234.0d0,5678.0d0)
+ if ( c .ne. f2c_4k(c) ) call abort
+ if ( c .ne. f2c_4l(i,c) ) call abort
+ if ( z .ne. f2c_4m(z) ) call abort
+ if ( z .ne. f2c_4n(i,z) ) call abort
+
end
real function f2c_4b(x)
double precision x
f2c_4b = x
end
+
+complex function f2c_4d(x)
+ complex x
+ f2c_4d = x
+end
+
+complex function f2c_4f(i,x)
+ complex x
+ integer i
+ f2c_4f = x
+end
+
+double complex function f2c_4h(x)
+ double complex x
+ f2c_4h = x
+end
+
+double complex function f2c_4j(i,x)
+ double complex x
+ f2c_4j = x
+end
RCS file: /cvs/gcc/gcc/gcc/testsuite/gfortran.dg/f2c_4.f90,v
retrieving revision 1.1
diff -u -r1.1 f2c_4.f90
--- f2c_4.f90 5 Jun 2005 23:42:19 -0000 1.1
+++ f2c_4.f90 23 Jun 2005 02:44:12 -0000
@@ -4,11 +4,55 @@
! Check -ff2c calling conventions
! Return value of REAL function is promoted to C type double
-! Addional underscore appended to function name
-call f2c_4a()
+! Return value of COMPLEX function is via an extra argument in the
+! calling sequence that points to where to store the return value
+! Addional underscore appended to function name
+program f2c_4
+ complex c, f2c_4k, f2c_4l
+ double complex z, f2c_4m, f2c_4n
+ integer i
+
+ ! Promotion of REAL function
+ call f2c_4a()
+
+ ! Return COMPLEX arg - call Fortran routines from C
+ call f2c_4c()
+ call f2c_4e()
+ call f2c_4g()
+ call f2c_4i()
+
+ ! Return COMPLEX arg - call C routines from Fortran
+ c = cmplx(1234.0,5678.0)
+ z = dcmplx(1234.0d0,5678.0d0)
+ if ( c .ne. f2c_4k(c) ) call abort
+ if ( c .ne. f2c_4l(i,c) ) call abort
+ if ( z .ne. f2c_4m(z) ) call abort
+ if ( z .ne. f2c_4n(i,z) ) call abort
+
end
real function f2c_4b(x)
double precision x
f2c_4b = x
end
+
+complex function f2c_4d(x)
+ complex x
+ f2c_4d = x
+end
+
+complex function f2c_4f(i,x)
+ complex x
+ integer i
+ f2c_4f = x
+end
+
+double complex function f2c_4h(x)
+ double complex x
+ f2c_4h = x
+end
+
+double complex function f2c_4j(i,x)
+ double complex x
+ f2c_4j = x
+end
NOTICE
This e-mail and any attachments are private and confidential and may contain privileged information. If you are not an authorised recipient, the copying or distribution of this e-mail and any attachments is prohibited and you must not read, print or act in reliance on this e-mail or attachments.
This notice should not be removed.