1b38e78ccSValentin Clement! RUN: bbc -emit-fir %s -o - | FileCheck %s 2b38e78ccSValentin Clement 3b38e78ccSValentin Clement! Test lowering of module that defines data that is otherwise not used 4b38e78ccSValentin Clement! in this file. 5b38e78ccSValentin Clement 62c8cb9acSJean Perier! Module defines variable in common block without initializer 72c8cb9acSJean Periermodule modCommonNoInit1 82c8cb9acSJean Perier ! Module variable is in blank common 92c8cb9acSJean Perier real :: x_blank 102c8cb9acSJean Perier common // x_blank 112c8cb9acSJean Perier ! Module variable is in named common, no init 122c8cb9acSJean Perier real :: x_named1 132c8cb9acSJean Perier common /named1/ x_named1 142c8cb9acSJean Perierend module 15*c1654c38SValentin Clement (バレンタイン クレメン)! CHECK-LABEL: fir.global common @__BLNK__(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8> 16*c1654c38SValentin Clement (バレンタイン クレメン)! CHECK-LABEL: fir.global common @named1_(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8> 172c8cb9acSJean Perier 182c8cb9acSJean Perier! Module defines variable in common block with initialization 192c8cb9acSJean Periermodule modCommonInit1 202c8cb9acSJean Perier integer :: i_named2 = 42 212c8cb9acSJean Perier common /named2/ i_named2 222c8cb9acSJean Perierend module 23*c1654c38SValentin Clement (バレンタイン クレメン)! CHECK-LABEL: fir.global @named2_ {alignment = 4 : i64} : tuple<i32> { 242c8cb9acSJean Perier ! CHECK: %[[init:.*]] = fir.insert_value %{{.*}}, %c42{{.*}}, [0 : index] : (tuple<i32>, i32) -> tuple<i32> 252c8cb9acSJean Perier ! CHECK: fir.has_value %[[init]] : tuple<i32> 262c8cb9acSJean Perier 27b38e78ccSValentin Clement! Module m1 defines simple data 28b38e78ccSValentin Clementmodule m1 29b38e78ccSValentin Clement real :: x 30b38e78ccSValentin Clement integer :: y(100) 31b38e78ccSValentin Clementend module 32b38e78ccSValentin Clement! CHECK: fir.global @_QMm1Ex : f32 33b38e78ccSValentin Clement! CHECK: fir.global @_QMm1Ey : !fir.array<100xi32> 34b38e78ccSValentin Clement 35b38e78ccSValentin Clement! Module modEq1 defines data that is equivalenced and not used in this 36b38e78ccSValentin Clement! file. 37b38e78ccSValentin Clementmodule modEq1 38b38e78ccSValentin Clement ! Equivalence, no initialization 39b38e78ccSValentin Clement real :: x1(10), x2(10), x3(10) 40b38e78ccSValentin Clement ! Equivalence with initialization 41b38e78ccSValentin Clement real :: y1 = 42. 42b38e78ccSValentin Clement real :: y2(10) 43b38e78ccSValentin Clement equivalence (x1(1), x2(5), x3(10)), (y1, y2(5)) 44b38e78ccSValentin Clementend module 45b38e78ccSValentin Clement! CHECK-LABEL: fir.global @_QMmodeq1Ex1 : !fir.array<76xi8> 46b38e78ccSValentin Clement! CHECK-LABEL: fir.global @_QMmodeq1Ey1 : !fir.array<10xi32> { 47b38e78ccSValentin Clement ! CHECK: %[[undef:.*]] = fir.undefined !fir.array<10xi32> 48b38e78ccSValentin Clement ! CHECK: %[[v1:.*]] = fir.insert_on_range %0, %c0{{.*}} from (0) to (3) : (!fir.array<10xi32>, i32) -> !fir.array<10xi32> 49b38e78ccSValentin Clement ! CHECK: %[[v2:.*]] = fir.insert_value %1, %c1109917696{{.*}}, [4 : index] : (!fir.array<10xi32>, i32) -> !fir.array<10xi32> 50b38e78ccSValentin Clement ! CHECK: %[[v3:.*]] = fir.insert_on_range %2, %c0{{.*}} from (5) to (9) : (!fir.array<10xi32>, i32) -> !fir.array<10xi32> 51b38e78ccSValentin Clement ! CHECK: fir.has_value %[[v3]] : !fir.array<10xi32> 52b38e78ccSValentin Clement 53b38e78ccSValentin Clement! Test defining two module variables whose initializers depend on each others 54b38e78ccSValentin Clement! addresses. 55b38e78ccSValentin Clementmodule global_init_depending_on_each_other_address 56b38e78ccSValentin Clement type a 57b38e78ccSValentin Clement type(b), pointer :: pb 58b38e78ccSValentin Clement end type 59b38e78ccSValentin Clement type b 60b38e78ccSValentin Clement type(a), pointer :: pa 61b38e78ccSValentin Clement end type 62b38e78ccSValentin Clement type(a), target :: xa 63b38e78ccSValentin Clement type(b), target :: xb 64b38e78ccSValentin Clement data xa, xb/a(xb), b(xa)/ 65b38e78ccSValentin Clementend module 66b38e78ccSValentin Clement! CHECK-LABEL: fir.global @_QMglobal_init_depending_on_each_other_addressExb 67b38e78ccSValentin Clement ! CHECK: fir.address_of(@_QMglobal_init_depending_on_each_other_addressExa) 68b38e78ccSValentin Clement! CHECK-LABEL: fir.global @_QMglobal_init_depending_on_each_other_addressExa 69b38e78ccSValentin Clement ! CHECK: fir.address_of(@_QMglobal_init_depending_on_each_other_addressExb) 70