xref: /llvm-project/flang/test/Lower/module_use.f90 (revision 4d21096c207847463a0253e0876c95c92e74adc3)
1! RUN: rm -fr %t && mkdir -p %t && cd %t
2! RUN: bbc -emit-fir %S/module_definition.f90
3! RUN: bbc -emit-fir %s -o - | FileCheck %s
4
5! Test use of module data not defined in this file.
6! The modules are defined in module_definition.f90
7! The first runs ensures the module file is generated.
8
9! CHECK: fir.global common @__BLNK__(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8>
10! CHECK-NEXT: fir.global common @named1_(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8>
11! CHECK-NEXT: fir.global common @named2_(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8>
12
13! CHECK-LABEL: func @_QPm1use()
14real function m1use()
15  use m1
16  ! CHECK-DAG: fir.address_of(@_QMm1Ex) : !fir.ref<f32>
17  ! CHECK-DAG: fir.address_of(@_QMm1Ey) : !fir.ref<!fir.array<100xi32>>
18  m1use = x + y(1)
19end function
20
21! TODO: test equivalences once front-end fix in module file is pushed.
22!! CHECK-LABEL func @_QPmodeq1use()
23!real function modEq1use()
24!  use modEq1
25!  ! CHECK-DAG fir.address_of(@_QMmodeq1Ex1) : !fir.ref<tuple<!fir.array<36xi8>, !fir.array<40xi8>>>
26!  ! CHECK-DAG fir.address_of(@_QMmodeq1Ey1) : !fir.ref<tuple<!fir.array<16xi8>, !fir.array<24xi8>>>
27!  modEq1use = x2(1) + y1
28!end function
29! CHECK-DAG fir.global @_QMmodeq1Ex1 : tuple<!fir.array<36xi8>, !fir.array<40xi8>>
30! CHECK-DAG fir.global @_QMmodeq1Ey1 : tuple<!fir.array<16xi8>, !fir.array<24xi8>>
31
32! CHECK-LABEL: func @_QPmodcommon1use()
33real function modCommon1Use()
34  use modCommonInit1
35  use modCommonNoInit1
36  ! CHECK-DAG: fir.address_of(@named2_) : !fir.ref<!fir.array<4xi8>>
37  ! CHECK-DAG: fir.address_of(@__BLNK__) : !fir.ref<!fir.array<4xi8>>
38  ! CHECK-DAG: fir.address_of(@named1_) : !fir.ref<!fir.array<4xi8>>
39  modCommon1Use = x_blank + x_named1 + i_named2
40end function
41
42
43! CHECK-DAG: fir.global @_QMm1Ex : f32
44! CHECK-DAG: fir.global @_QMm1Ey : !fir.array<100xi32>
45