File: module_definition.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 (69 lines) | stat: -rw-r--r-- 2,645 bytes parent folder | download | duplicates (2)
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
! RUN: bbc -emit-fir %s -o - | FileCheck %s

! Test lowering of module that defines data that is otherwise not used
! in this file.

! Module defines variable in common block without initializer
module modCommonNoInit1
  ! Module variable is in blank common
  real :: x_blank
  common // x_blank
  ! Module variable is in named common, no init
  real :: x_named1
  common /named1/ x_named1
end module
! CHECK-LABEL: fir.global common @_QC(dense<0> : vector<4xi8>) : !fir.array<4xi8>
! CHECK-LABEL: fir.global common @_QCnamed1(dense<0> : vector<4xi8>) : !fir.array<4xi8>

! Module defines variable in common block with initialization
module modCommonInit1
  integer :: i_named2 = 42
  common /named2/ i_named2
end module
! CHECK-LABEL: fir.global @_QCnamed2 : tuple<i32> {
  ! CHECK: %[[init:.*]] = fir.insert_value %{{.*}}, %c42{{.*}}, [0 : index] : (tuple<i32>, i32) -> tuple<i32>
  ! CHECK: fir.has_value %[[init]] : tuple<i32>

! Module m1 defines simple data
module m1
  real :: x
  integer :: y(100)
end module
! CHECK: fir.global @_QMm1Ex : f32
! CHECK: fir.global @_QMm1Ey : !fir.array<100xi32>

! Module modEq1 defines data that is equivalenced and not used in this
! file.
module modEq1
  ! Equivalence, no initialization
  real :: x1(10), x2(10), x3(10) 
  ! Equivalence with initialization
  real :: y1 = 42.
  real :: y2(10)
  equivalence (x1(1), x2(5), x3(10)), (y1, y2(5))
end module
! CHECK-LABEL: fir.global @_QMmodeq1Ex1 : !fir.array<76xi8>
! CHECK-LABEL: fir.global @_QMmodeq1Ey1 : !fir.array<10xi32> {
  ! CHECK: %[[undef:.*]] = fir.undefined !fir.array<10xi32>
  ! CHECK: %[[v1:.*]] = fir.insert_on_range %0, %c0{{.*}} from (0) to (3) : (!fir.array<10xi32>, i32) -> !fir.array<10xi32>
  ! CHECK: %[[v2:.*]] = fir.insert_value %1, %c1109917696{{.*}}, [4 : index] : (!fir.array<10xi32>, i32) -> !fir.array<10xi32>
  ! CHECK: %[[v3:.*]] = fir.insert_on_range %2, %c0{{.*}} from (5) to (9) : (!fir.array<10xi32>, i32) -> !fir.array<10xi32>
  ! CHECK: fir.has_value %[[v3]] : !fir.array<10xi32>

! Test defining two module variables whose initializers depend on each others
! addresses.
module global_init_depending_on_each_other_address
  type a
    type(b), pointer :: pb
  end type
  type b
    type(a), pointer :: pa
  end type
  type(a), target :: xa
  type(b), target :: xb
  data xa, xb/a(xb), b(xa)/
end module
! CHECK-LABEL: fir.global @_QMglobal_init_depending_on_each_other_addressExb
  ! CHECK: fir.address_of(@_QMglobal_init_depending_on_each_other_addressExa)
! CHECK-LABEL: fir.global @_QMglobal_init_depending_on_each_other_addressExa
  ! CHECK: fir.address_of(@_QMglobal_init_depending_on_each_other_addressExb)