| 1 |
! { dg-do run } |
| 2 |
! { dg-additional-sources f2c_4.c } |
| 3 |
! { dg-options "-ff2c -w" } |
| 4 |
|
| 5 |
! Check -ff2c calling conventions |
| 6 |
! Return value of REAL function is promoted to C type double |
| 7 |
! Return value of COMPLEX function is via an extra argument in the |
| 8 |
! calling sequence that points to where to store the return value |
| 9 |
! Addional underscore appended to function name |
| 10 |
program f2c_4 |
| 11 |
complex c, f2c_4k, f2c_4l |
| 12 |
double complex z, f2c_4m, f2c_4n |
| 13 |
integer i |
| 14 |
|
| 15 |
! Promotion of REAL function |
| 16 |
call f2c_4a() |
| 17 |
|
| 18 |
! Return COMPLEX arg - call Fortran routines from C |
| 19 |
call f2c_4c() |
| 20 |
call f2c_4e() |
| 21 |
call f2c_4g() |
| 22 |
call f2c_4i() |
| 23 |
|
| 24 |
! Return COMPLEX arg - call C routines from Fortran |
| 25 |
c = cmplx(1234.0,5678.0) |
| 26 |
z = dcmplx(1234.0d0,5678.0d0) |
| 27 |
if ( c .ne. f2c_4k(c) ) STOP 1 |
| 28 |
if ( c .ne. f2c_4l(i,c) ) STOP 2 |
| 29 |
if ( z .ne. f2c_4m(z) ) STOP 3 |
| 30 |
if ( z .ne. f2c_4n(i,z) ) STOP 4 |
| 31 |
|
| 32 |
end |
| 33 |
|
| 34 |
real function f2c_4b(x) |
| 35 |
double precision x |
| 36 |
f2c_4b = x |
| 37 |
end |
| 38 |
|
| 39 |
complex function f2c_4d(x) |
| 40 |
complex x |
| 41 |
f2c_4d = x |
| 42 |
end |
| 43 |
|
| 44 |
complex function f2c_4f(i,x) |
| 45 |
complex x |
| 46 |
integer i |
| 47 |
f2c_4f = x |
| 48 |
end |
| 49 |
|
| 50 |
double complex function f2c_4h(x) |
| 51 |
double complex x |
| 52 |
f2c_4h = x |
| 53 |
end |
| 54 |
|
| 55 |
double complex function f2c_4j(i,x) |
| 56 |
double complex x |
| 57 |
f2c_4j = x |
| 58 |
end |