Merge from mainline.
[official-gcc.git] / gcc / testsuite / gfortran.dg / f2c_4.f90
bloba0d1909bf2f4a8cb1928608eaf96291184aed67e
1 ! { dg-do run }
2 ! { dg-additional-sources f2c_4.c }
3 ! { dg-options "-ff2c -w" }
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
15 ! Promotion of REAL function
16 call f2c_4a()
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()
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) ) call abort
28 if ( c .ne. f2c_4l(i,c) ) call abort
29 if ( z .ne. f2c_4m(z) ) call abort
30 if ( z .ne. f2c_4n(i,z) ) call abort
32 end
34 real function f2c_4b(x)
35 double precision x
36 f2c_4b = x
37 end
39 complex function f2c_4d(x)
40 complex x
41 f2c_4d = x
42 end
44 complex function f2c_4f(i,x)
45 complex x
46 integer i
47 f2c_4f = x
48 end
50 double complex function f2c_4h(x)
51 double complex x
52 f2c_4h = x
53 end
55 double complex function f2c_4j(i,x)
56 double complex x
57 f2c_4j = x
58 end