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