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