File: offsets02.f90

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,696 kB
  • sloc: cpp: 7,438,781; ansic: 1,393,871; asm: 1,012,926; python: 241,771; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 8,596; ml: 5,082; perl: 4,730; makefile: 3,591; awk: 3,523; javascript: 2,251; xml: 892; fortran: 672
file content (70 lines) | stat: -rw-r--r-- 1,695 bytes parent folder | download | duplicates (11)
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
!RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s

! Size and alignment of derived types

! Array of derived type with 64-bit alignment
subroutine s1
  type t1
    real(8) :: a
    real(4) :: b
  end type
  type t2
    type(t1) c
    real(4) d
  end type
  !CHECK: x1 size=16 offset=0:
  !CHECK: y1 size=16 offset=16:
  type(t1) :: x1, y1
  !CHECK: z1 size=160 offset=32:
  type(t1) :: z1(10)
  !CHECK: z2 size=24 offset=192
  type(t2) z2
end

! Like t1 but t2 does not need to be aligned on 64-bit boundary
subroutine s2
  type t2
    real(4) :: a
    real(4) :: b
    real(4) :: c
  end type
  !CHECK: x2 size=12 offset=0:
  !CHECK: y2 size=12 offset=12:
  type(t2) :: x2, y2
  !CHECK: z2 size=120 offset=24:
  type(t2) :: z2(10)
end

! Parameterized derived types
subroutine s3
  type :: t(k, l)
    integer, kind :: k
    integer, len :: l
    real(k) :: a3
    integer(kind=k) :: b3
    character(kind=k, len=8) :: c3
    character(kind=k, len=l) :: d3
  end type
  !CHECK: DerivedType scope: size=48 alignment=8 instantiation of t(k=2_4,l=10_4)
  !CHECK: a3 size=2 offset=0:
  !CHECK: b3 size=2 offset=2:
  !CHECK: c3 size=16 offset=4:
  !CHECK: d3 size=24 offset=24:
  type(t(2, 10)) :: x3
  !CHECK: DerivedType scope: size=64 alignment=8 instantiation of t(k=4_4,l=20_4)
  !CHECK: a3 size=4 offset=0:
  !CHECK: b3 size=4 offset=4:
  !CHECK: c3 size=32 offset=8:
  !CHECK: d3 size=24 offset=40:
  type(t(4, 20)) :: x4
end

subroutine s4
  type t(k)
    integer, kind :: k
    character(len=k) :: c
  end type
  type(t(7)) :: x4
  !CHECK: DerivedType scope: size=7 alignment=1 instantiation of t(k=7_4)
  !CHECK: c size=7 offset=0: ObjectEntity type: CHARACTER(7_4,1)
end subroutine