79 lines · plain
1! Test that module variables with an initializer are only defined once,2! except for compiler generated derived type descriptor that should be3! always fully defined as linkonce_odr by the compilation units defining or4! using them.5! Test that this holds true in contexts with namelist members that are special6! because the symbol on the use site are not symbols with semantics::UseDetails,7! but directly the symbols from the module scope.8 9 10! RUN: split-file %s %t11! RUN: bbc -emit-fir %t/definition-a.f90 -o - | FileCheck %s --check-prefix=CHECK-A-DEF12! RUN: bbc -emit-fir %t/definition-b.f90 -o - | FileCheck %s --check-prefix=CHECK-B-DEF13! RUN: bbc -emit-fir %t/use.f90 -o - | FileCheck %s --check-prefix=CHECK-USE14 15 16 17!--- definition-a.f9018 19! Test definition of `atype` derived type descriptor as `linkonce_odr`20module define_a21 type atype22 real :: x23 end type24end module25 26! CHECK-A-DEF: fir.global linkonce_odr @_QMdefine_aE.dt.atype constant target : !fir.type<{{.*}}> {27! CHECK-A-DEF: fir.has_value28! CHECK-A-DEF: }29 30!--- definition-b.f9031 32! Test define_b `i` is defined here.33! Also test that the derived type descriptor of types defined here (`btype`) and used34! here (`atype`) are fully defined here as linkonce_odr.35module define_b36 use :: define_a37 type btype38 type(atype) :: atype39 end type40 integer :: i = 4241 namelist /some_namelist/ i42end module43 44! CHECK-B-DEF: fir.global @_QMdefine_bEi : i32 {45! CHECK-B-DEF: fir.has_value %{{.*}} : i3246! CHECK-B-DEF: }47 48! CHECK-B-DEF: fir.global linkonce_odr @_QMdefine_bE.dt.btype constant target : !fir.type<{{.*}}> {49! CHECK-B-DEF: fir.has_value50! CHECK-B-DEF: }51 52! CHECK-B-DEF: fir.global linkonce_odr @_QMdefine_aE.dt.atype constant : !fir.type<{{.*}}> {53! CHECK-B-DEF: fir.has_value54! CHECK-B-DEF: }55 56 57 58!--- use.f9059 60! Test define_b `i` is declared but not defined here and that derived types61! descriptors are fully defined as linkonce_odr here.62subroutine foo()63 use :: define_b64 type(btype) :: somet65 print *, somet66 write(*, some_namelist)67end subroutine68! CHECK-USE: fir.global @_QMdefine_bEi : i32{{$}}69! CHECK-USE-NOT: fir.has_value %{{.*}} : i3270 71! CHECK-USE: fir.global linkonce_odr @_QMdefine_aE.dt.atype constant : !fir.type<{{.*}}> {72! CHECK-USE: fir.has_value73! CHECK-USE: }74 75! CHECK-USE: fir.global linkonce_odr @_QMdefine_bE.dt.btype constant : !fir.type<{{.*}}> {76! CHECK-USE: fir.has_value77! CHECK-USE: }78 79