Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / offsets02.f90
blob387bbac5ff6d43860400ed2950648ee0fd262dba
1 !RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
3 ! Size and alignment of derived types
5 ! Array of derived type with 64-bit alignment
6 subroutine s1
7 type t1
8 real(8) :: a
9 real(4) :: b
10 end type
11 !CHECK: x1 size=12 offset=0:
12 !CHECK: y1 size=12 offset=16:
13 type(t1) :: x1, y1
14 !CHECK: z1 size=160 offset=32:
15 type(t1) :: z1(10)
16 end
18 ! Like t1 but t2 does not need to be aligned on 64-bit boundary
19 subroutine s2
20 type t2
21 real(4) :: a
22 real(4) :: b
23 real(4) :: c
24 end type
25 !CHECK: x2 size=12 offset=0:
26 !CHECK: y2 size=12 offset=12:
27 type(t2) :: x2, y2
28 !CHECK: z2 size=120 offset=24:
29 type(t2) :: z2(10)
30 end
32 ! Parameterized derived types
33 subroutine s3
34 type :: t(k, l)
35 integer, kind :: k
36 integer, len :: l
37 real(k) :: a3
38 integer(kind=k) :: b3
39 character(kind=k, len=8) :: c3
40 character(kind=k, len=l) :: d3
41 end type
42 !CHECK: DerivedType scope: size=48 alignment=8 instantiation of t(k=2_4,l=10_4)
43 !CHECK: a3 size=2 offset=0:
44 !CHECK: b3 size=2 offset=2:
45 !CHECK: c3 size=16 offset=4:
46 !CHECK: d3 size=24 offset=24:
47 type(t(2, 10)) :: x3
48 !CHECK: DerivedType scope: size=64 alignment=8 instantiation of t(k=4_4,l=20_4)
49 !CHECK: a3 size=4 offset=0:
50 !CHECK: b3 size=4 offset=4:
51 !CHECK: c3 size=32 offset=8:
52 !CHECK: d3 size=24 offset=40:
53 type(t(4, 20)) :: x4
54 end
56 subroutine s4
57 type t(k)
58 integer, kind :: k
59 character(len=k) :: c
60 end type
61 type(t(7)) :: x4
62 !CHECK: DerivedType scope: size=7 alignment=1 instantiation of t(k=7_4)
63 !CHECK: c size=7 offset=0: ObjectEntity type: CHARACTER(7_4,1)
64 end subroutine