aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/host_assoc_function_3.f90
blob: cebe646fa583699c0dbbb6491c6d57e86993b0f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
! { dg-do run }
! Tests the fix for the bug PR33233, in which the reference to 'x'
! in 'inner' wrongly host-associated with the variable 'x' rather
! than the function.
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
!
MODULE m
  REAL :: x(3) = (/ 1.5, 2.5, 3.5 /)
CONTAINS
  SUBROUTINE s
    if (x(2) .eq. 2.5) call abort ()
  CONTAINS
    FUNCTION x(n, m)
      integer, optional :: m
      if (present(m)) then
        x = REAL(n)**m
      else
        x = 0.0
      end if
    END FUNCTION
  END SUBROUTINE s
END MODULE m
  use m
  call s
end