1! Test that module data access are lowered correctly in the different
2! procedure contexts.
3! RUN: bbc -emit-fir %s -o - | FileCheck %s
4
5module parent
6  integer :: i
7contains
8! Test simple access to the module data
9! CHECK-LABEL: func @_QMparentPtest1
10subroutine test1()
11  ! CHECK: fir.address_of(@_QMparentEi) : !fir.ref<i32>
12  print *, i
13end subroutine
14
15! Test access to the module data inside an internal procedure where the
16! host is defined inside the module.
17subroutine test2()
18  call test2internal()
19  contains
20  ! CHECK-LABEL: func @_QMparentFtest2Ptest2internal()
21  subroutine test2internal()
22    ! CHECK: fir.address_of(@_QMparentEi) : !fir.ref<i32>
23    print *, i
24  end subroutine
25end subroutine
26end module
27
28! Test access to the module data inside an internal procedure where the
29! host is using the module.
30subroutine test3()
31  use parent
32  call test3internal()
33  contains
34  ! CHECK-LABEL: func @_QFtest3Ptest3internal()
35  subroutine test3internal()
36    ! CHECK: fir.address_of(@_QMparentEi) : !fir.ref<i32>
37    print *, i
38  end subroutine
39end subroutine
40