3 ! Checks the fix for PR33541, in which a requirement of
4 ! F95 11.3.2 was not being met: The local names 'x' and
5 ! 'y' coming from the USE statements without an ONLY clause
6 ! should not survive in the presence of the locally renamed
7 ! versions. In fixing the PR, the same correction has been
8 ! made to generic interfaces.
10 ! Reported by Reported by John Harper in
11 ! http://gcc.gnu.org/ml/fortran/2007-09/msg00397.html
14 integer(4) :: x
= -666
17 module procedure foo
, bar
20 integer function foo ()
23 integer function bar (a
)
30 integer(4) :: y
= -666
33 module procedure foo
, bar
36 integer function foo ()
39 integer function bar (a
)
45 integer function xfoobar () ! These function as defaults should...
49 integer function yfoobar () ! ...the rename works correctly.
54 implicit integer(2) (a
-z
)
55 x
= 666 ! These assignments generate implicitly typed
56 y
= 666 ! local variables 'x' and 'y'.
61 subroutine test1
! Test the fix of the original PR
63 USE xmod
, ONLY
: xrenamed
=> x
64 USE ymod
, ONLY
: yrenamed
=> y
66 implicit integer(2) (a
-z
)
67 if (kind(xrenamed
) == kind(x
)) call abort ()
68 if (kind(yrenamed
) == kind(y
)) call abort ()
71 subroutine test2
! Test the fix applies to generic interfaces
73 USE xmod
, ONLY
: xfoobar_renamed
=> xfoobar
74 USE ymod
, ONLY
: yfoobar_renamed
=> yfoobar
76 implicit integer(4) (a
-z
)
77 if (xfoobar_renamed (42) == xfoobar ()) call abort ()
78 if (yfoobar_renamed (42) == yfoobar ()) call abort ()
81 subroutine test3
! Check that USE_NAME == LOCAL_NAME is OK
83 USE xmod
, ONLY
: x
=> x
, xfoobar
=> xfoobar
84 USE ymod
, ONLY
: y
=> y
, yfoobar
=> yfoobar
86 if (kind (x
) /= 4) call abort ()
87 if (kind (y
) /= 4) call abort ()
88 if (xfoobar (77) /= 77_4) call abort ()
89 if (yfoobar (77) /= 77_4) call abort ()