c: Fix up pointer types to may_alias structures [PR114493]
[official-gcc.git] / gcc / testsuite / gfortran.dg / f2c_6.f90
blob63cb61a1df27ad371a67feb9e539b4acf3144812
1 ! { dg-do run }
2 ! { dg-options "-ff2c" }
3 ! Verifies that complex pointer results work with -ff2c
4 ! try all permutations of result clause in function yes/no
5 ! and result clause in interface yes/no
6 ! this is not possible in Fortran 77, but this exercises a previously
7 ! buggy codepath
8 function c() result (r)
9 common // z
10 complex, pointer :: r
11 complex, target :: z
13 r=>z
14 end function c
16 function d()
17 common // z
18 complex, pointer :: d
19 complex, target :: z
21 d=>z
22 end function d
24 function e()
25 common // z
26 complex, pointer :: e
27 complex, target :: z
29 e=>z
30 end function e
32 function f() result(r)
33 common // z
34 complex, pointer :: r
35 complex, target :: z
37 r=>z
38 end function f
40 interface
41 function c ()
42 complex, pointer :: c
43 end function c
44 end interface
45 interface
46 function d()
47 complex, pointer :: d
48 end function d
49 end interface
50 interface
51 function e () result(r)
52 complex, pointer :: r
53 end function e
54 end interface
55 interface
56 function f () result(r)
57 complex, pointer :: r
58 end function f
59 end interface
61 common // z
62 complex, target :: z
63 complex, pointer :: p
65 z = (1.,0.)
66 p => c()
67 z = (2.,0.)
68 if (p /= z) STOP 1
70 NULLIFY(p)
71 p => d()
72 z = (3.,0.)
73 if (p /= z) STOP 2
75 NULLIFY(p)
76 p => e()
77 z = (4.,0.)
78 if (p /= z) STOP 3
80 NULLIFY(p)
81 p => f()
82 z = (5.,0.)
83 if (p /= z) STOP 4
84 end