summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/host_assoc_function_9.f90
blob: 58cae435fb6be317756341bb9b638a986f7e564e (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
27
28
29
30
31
32
33
! { dg-do run }
! Tests the fix for the bug PR40629, in which the reference to 'x'
! in 'upper' wrongly host-associated with the symbol 'x' at module
! leve rather than the function.
!
! Contributed by Philippe Marguinaud  <philippe.marguinaud@meteo.fr>
!
MODULE m
  REAL :: x = 0
CONTAINS
  subroutine s
    call upper
    call lower
  CONTAINS
    SUBROUTINE upper
     y = x(3,1)
     if (int(y) .ne. 3) call abort
    END SUBROUTINE
    FUNCTION x(n, m)
       x = m*n
    END FUNCTION
    SUBROUTINE lower
     y = x(2,1)
     if (int(y) .ne. 2) call abort
    END SUBROUTINE
  END SUBROUTINE
END MODULE

  use m
  call s
end
! { dg-final { cleanup-modules "m" } }