[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / namelist.f90
blob0a9a5b34b93872f97816aea75731ac3f9ed1f204
1 ! RUN: bbc -emit-fir -o - %s | FileCheck %s
3 ! CHECK-LABEL: func @_QQmain
4 program p
5 ! CHECK-DAG: [[ccc:%[0-9]+]] = fir.alloca !fir.array<4x!fir.char<1,3>> {bindc_name = "ccc", uniq_name = "_QFEccc"}
6 ! CHECK-DAG: [[jjj:%[0-9]+]] = fir.alloca i32 {bindc_name = "jjj", uniq_name = "_QFEjjj"}
7 character*3 ccc(4)
8 namelist /nnn/ jjj, ccc
9 jjj = 17
10 ccc = ["aa ", "bb ", "cc ", "dd "]
11 ! CHECK: [[cookie:%[0-9]+]] = fir.call @_FortranAioBeginExternalListOutput
12 ! CHECK: fir.alloca !fir.array<2xtuple<!fir.ref<i8>, !fir.ref<!fir.box<none>>>>
13 ! CHECK: fir.undefined
14 ! CHECK: fir.address_of
15 ! CHECK: fir.insert_value
16 ! CHECK: fir.embox [[jjj]]
17 ! CHECK: fir.insert_value
18 ! CHECK: fir.address_of
19 ! CHECK: fir.insert_value
20 ! CHECK: fir.embox [[ccc]]
21 ! CHECK: fir.insert_value
22 ! CHECK: fir.alloca tuple<!fir.ref<i8>, i64, !fir.ref<!fir.array<2xtuple<!fir.ref<i8>, !fir.ref<!fir.box<none>>>>>>
23 ! CHECK: fir.address_of
24 ! CHECK-COUNT-3: fir.insert_value
25 ! CHECK: fir.call @_FortranAioOutputNamelist([[cookie]]
26 ! CHECK: fir.call @_FortranAioEndIoStatement([[cookie]]
27 write(*, nnn)
28 jjj = 27
29 ! CHECK: fir.coordinate_of
30 ccc(4) = "zz "
31 ! CHECK: [[cookie:%[0-9]+]] = fir.call @_FortranAioBeginExternalListOutput
32 ! CHECK: fir.alloca !fir.array<2xtuple<!fir.ref<i8>, !fir.ref<!fir.box<none>>>>
33 ! CHECK: fir.undefined
34 ! CHECK: fir.address_of
35 ! CHECK: fir.insert_value
36 ! CHECK: fir.embox [[jjj]]
37 ! CHECK: fir.insert_value
38 ! CHECK: fir.address_of
39 ! CHECK: fir.insert_value
40 ! CHECK: fir.embox [[ccc]]
41 ! CHECK: fir.insert_value
42 ! CHECK: fir.alloca tuple<!fir.ref<i8>, i64, !fir.ref<!fir.array<2xtuple<!fir.ref<i8>, !fir.ref<!fir.box<none>>>>>>
43 ! CHECK: fir.address_of
44 ! CHECK-COUNT-3: fir.insert_value
45 ! CHECK: fir.call @_FortranAioOutputNamelist([[cookie]]
46 ! CHECK: fir.call @_FortranAioEndIoStatement([[cookie]]
47 write(*, nnn)
48 end
50 ! CHECK-LABEL: sss
51 subroutine sss
52 integer xxx(11:13)
53 namelist /rrr/ xxx
54 ! CHECK: [[xxx:%[0-9]+]] = fir.alloca {{.*}} = "xxx"
55 ! CHECK: [[cookie:%[0-9]+]] = fir.call @_FortranAioBeginExternalListInput
56 ! CHECK: alloca
57 ! CHECK: undefined
58 ! CHECK: fir.address_of{{.*}}787878
59 ! CHECK: fir.insert_value
60 ! CHECK: fir.shape_shift %c11
61 ! CHECK: fir.embox [[xxx]]
62 ! CHECK: fir.insert_value
63 ! CHECK: fir.alloca
64 ! CHECK: fir.undefined
65 ! CHECK: fir.address_of{{.*}}727272
66 ! CHECK-COUNT-3: fir.insert_value
67 ! CHECK: fir.call @_FortranAioInputNamelist([[cookie]]
68 ! CHECK: fir.call @_FortranAioEndIoStatement([[cookie]]
69 read(*, rrr)
70 end
72 ! CHECK-LABEL: global_pointer
73 subroutine global_pointer
74 real,pointer,save::ptrarray(:)
75 ! CHECK: %[[a0:.*]] = fir.address_of
76 namelist/mygroup/ptrarray
77 ! CHECK: %[[a1:.*]] = fir.convert %[[a0]]
78 ! CHECK: %[[a2:.*]] = fir.call @_FortranAioBeginExternalListOutput({{.*}}, %[[a1]], {{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
79 ! CHECK: %[[a3:.*]] = fir.address_of
80 ! CHECK: %[[a4:.*]] = fir.convert %[[a3]]
81 ! CHECK: %[[a5:.*]] = fir.call @_FortranAioOutputNamelist(%[[a2]], %[[a4]])
82 ! CHECK: %[[a6:.*]] = fir.call @_FortranAioEndIoStatement(%[[a2]])
83 write(10, nml=mygroup)
84 end
86 ! CHECK-DAG: fir.global linkonce @_QQcl.6A6A6A00 constant : !fir.char<1,4>
87 ! CHECK-DAG: fir.global linkonce @_QQcl.63636300 constant : !fir.char<1,4>
88 ! CHECK-DAG: fir.global linkonce @_QQcl.6E6E6E00 constant : !fir.char<1,4>