[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Evaluate / folding17.f90
blob73ddeabcab3d25843d7750664f85c7d09fab5367
1 ! RUN: %python %S/test_folding.py %s %flang_fc1
2 ! Test implementations of STORAGE_SIZE() and SIZEOF() as expression rewrites
3 module m1
4 type :: t1
5 real :: a(2,3)
6 character*5 :: c(3)
7 end type
8 type :: t2(k)
9 integer, kind :: k
10 type(t1) :: a(k)
11 end type
12 type(t2(2)) :: a(2)
13 integer, parameter :: ss1 = storage_size(a(1)%a(1)%a)
14 integer, parameter :: sz1 = sizeof(a(1)%a(1)%a)
15 integer, parameter :: ss2 = storage_size(a(1)%a(1)%c)
16 integer, parameter :: sz2 = sizeof(a(1)%a(1)%c)
17 integer, parameter :: ss3 = storage_size(a(1)%a)
18 integer, parameter :: sz3 = sizeof(a(1)%a)
19 integer, parameter :: ss4 = storage_size(a)
20 integer, parameter :: sz4 = sizeof(a)
21 logical, parameter :: test_ss = all([ss1,ss2,ss3,ss4]==[32, 40, 320, 640])
22 logical, parameter :: test_sz = all([sz1,sz2,sz3,sz4]==[24, 15, 80, 160])
23 end module