File: module-single-point-of-def.f90

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (78 lines) | stat: -rw-r--r-- 2,403 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
! Test that module variables with an initializer are only defined once,
! except for compiler generated derived type descriptor that should be
! always fully defined as linkonce_odr by the compilation units defining or
! using them.
! Test that this holds true in contexts with namelist members that are special
! because the symbol on the use site are not symbols with semantics::UseDetails,
! but directly the symbols from the module scope.


! RUN: split-file %s %t
! RUN: bbc -emit-fir %t/definition-a.f90 -o - | FileCheck %s --check-prefix=CHECK-A-DEF
! RUN: bbc -emit-fir %t/definition-b.f90 -o - | FileCheck %s --check-prefix=CHECK-B-DEF
! RUN: bbc -emit-fir %t/use.f90 -o - | FileCheck %s --check-prefix=CHECK-USE



!--- definition-a.f90

! Test definition of `atype` derived type descriptor as `linkonce_odr`
module define_a
  type atype
    real :: x
  end type
end module

! CHECK-A-DEF: fir.global linkonce_odr @_QMdefine_aE.dt.atype constant target : !fir.type<{{.*}}> {
! CHECK-A-DEF: fir.has_value
! CHECK-A-DEF: }

!--- definition-b.f90

! Test define_b `i` is defined here.
! Also test that the derived type descriptor of types defined here (`btype`) and used
! here (`atype`) are fully defined here as linkonce_odr.
module define_b
  use :: define_a
  type btype
    type(atype) :: atype
  end type
  integer :: i = 42
  namelist /some_namelist/ i
end module

! CHECK-B-DEF: fir.global @_QMdefine_bEi : i32 {
! CHECK-B-DEF: fir.has_value %{{.*}} : i32
! CHECK-B-DEF: }

! CHECK-B-DEF: fir.global linkonce_odr @_QMdefine_bE.dt.btype constant target : !fir.type<{{.*}}> {
! CHECK-B-DEF: fir.has_value
! CHECK-B-DEF: }

! CHECK-B-DEF: fir.global linkonce_odr @_QMdefine_aE.dt.atype constant : !fir.type<{{.*}}> {
! CHECK-B-DEF: fir.has_value
! CHECK-B-DEF: }



!--- use.f90

! Test  define_b `i` is declared but not defined here and that derived types
! descriptors are fully defined as linkonce_odr here.
subroutine foo()
  use :: define_b
  type(btype) :: somet
  print *, somet
  write(*, some_namelist)
end subroutine
! CHECK-USE: fir.global @_QMdefine_bEi : i32{{$}}
! CHECK-USE-NOT: fir.has_value %{{.*}} : i32

! CHECK-USE: fir.global linkonce_odr @_QMdefine_aE.dt.atype constant : !fir.type<{{.*}}> {
! CHECK-USE: fir.has_value
! CHECK-USE: }

! CHECK-USE: fir.global linkonce_odr @_QMdefine_bE.dt.btype constant : !fir.type<{{.*}}> {
! CHECK-USE: fir.has_value
! CHECK-USE: }