1 ! Test that module variables with an initializer are only defined once,
2 ! except for compiler generated derived type descriptor that should be
3 ! always fully defined as linkonce_odr by the compilation units defining or
5 ! Test that this holds true in contexts with namelist members that are special
6 ! because the symbol on the use site are not symbols with semantics::UseDetails,
7 ! but directly the symbols from the module scope.
10 ! RUN: split-file %s %t
11 ! RUN: bbc -emit-fir %t/definition-a.f90 -o - | FileCheck %s --check-prefix=CHECK-A-DEF
12 ! RUN: bbc -emit-fir %t/definition-b.f90 -o - | FileCheck %s --check-prefix=CHECK-B-DEF
13 ! RUN: bbc -emit-fir %t/use.f90 -o - | FileCheck %s --check-prefix=CHECK-USE
19 ! Test definition of `atype` derived type descriptor as `linkonce_odr`
26 ! CHECK-A-DEF: fir.global linkonce_odr @_QMdefine_aE.dt.atype constant target : !fir.type<{{.*}}> {
27 ! CHECK-A-DEF: fir.has_value
32 ! Test define_b `i` is defined here.
33 ! Also test that the derived type descriptor of types defined here (`btype`) and used
34 ! here (`atype`) are fully defined here as linkonce_odr.
41 namelist /some_namelist
/ i
44 ! CHECK-B-DEF: fir.global @_QMdefine_bEi : i32 {
45 ! CHECK-B-DEF: fir.has_value %{{.*}} : i32
48 ! CHECK-B-DEF: fir.global linkonce_odr @_QMdefine_bE.dt.btype constant target : !fir.type<{{.*}}> {
49 ! CHECK-B-DEF: fir.has_value
52 ! CHECK-B-DEF: fir.global linkonce_odr @_QMdefine_aE.dt.atype constant : !fir.type<{{.*}}> {
53 ! CHECK-B-DEF: fir.has_value
60 ! Test define_b `i` is declared but not defined here and that derived types
61 ! descriptors are fully defined as linkonce_odr here.
66 write(*, some_namelist
)
68 ! CHECK-USE: fir.global @_QMdefine_bEi : i32{{$}}
69 ! CHECK-USE-NOT: fir.has_value %{{.*}} : i32
71 ! CHECK-USE: fir.global linkonce_odr @_QMdefine_aE.dt.atype constant : !fir.type<{{.*}}> {
72 ! CHECK-USE: fir.has_value
75 ! CHECK-USE: fir.global linkonce_odr @_QMdefine_bE.dt.btype constant : !fir.type<{{.*}}> {
76 ! CHECK-USE: fir.has_value