From 30bfb6a7f641f96da2d525f98afa84040e56ed6c Mon Sep 17 00:00:00 2001 From: Jean Perier Date: Tue, 7 Mar 2023 08:59:57 +0100 Subject: [PATCH] [flang][hlfir] Map scalar character symbols in internal procedures I missed `addCharSymbol` in the patch adding the hlfir.declare in internal procedures for "captured" entities (https://reviews.llvm.org/D143481). Differential Revision: https://reviews.llvm.org/D145361 --- flang/lib/Lower/HostAssociations.cpp | 4 +++- flang/test/Lower/HLFIR/internal-procedures.f90 | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/flang/lib/Lower/HostAssociations.cpp b/flang/lib/Lower/HostAssociations.cpp index 4d8a120..008e4fc 100644 --- a/flang/lib/Lower/HostAssociations.cpp +++ b/flang/lib/Lower/HostAssociations.cpp @@ -243,7 +243,9 @@ public: args.loc); std::pair unboxchar = charHelp.createUnboxChar(args.valueInTuple); - args.symMap.addCharSymbol(sym, unboxchar.first, unboxchar.second); + bindCapturedSymbol(sym, + fir::CharBoxValue{unboxchar.first, unboxchar.second}, + converter, args.symMap); } }; diff --git a/flang/test/Lower/HLFIR/internal-procedures.f90 b/flang/test/Lower/HLFIR/internal-procedures.f90 index 4ad272e..ca3ec3e 100644 --- a/flang/test/Lower/HLFIR/internal-procedures.f90 +++ b/flang/test/Lower/HLFIR/internal-procedures.f90 @@ -36,3 +36,19 @@ end subroutine ! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_4]] : (!fir.box>, index) -> (index, index, index) ! CHECK: %[[VAL_6:.*]] = fir.shift %[[VAL_5]]#0 : (index) -> !fir.shift<1> ! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_3]](%[[VAL_6]]) {uniq_name = "_QFtest_assumed_shapeEx"} : (!fir.box>, !fir.shift<1>) -> (!fir.box>, !fir.box>) + +subroutine test_scalar_char(c) + character(*) :: c +contains +subroutine internal() + call bar(c) +end subroutine +end subroutine +! CHECK-LABEL: func.func @_QFtest_scalar_charPinternal( +! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>> {fir.host_assoc}) attributes {fir.internal_proc} { +! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32 +! CHECK: %[[VAL_2:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_1]] : (!fir.ref>>, i32) -> !fir.ref> +! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_2]] : !fir.ref> +! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_3]] : (!fir.boxchar<1>) -> (!fir.ref>, index) +! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]]#0 typeparams %[[VAL_4]]#1 {uniq_name = "_QFtest_scalar_charEc"} : (!fir.ref>, index) -> (!fir.boxchar<1>, !fir.ref>) +! CHECK: fir.call @_QPbar(%[[VAL_5]]#0) {{.*}}: (!fir.boxchar<1>) -> () -- 2.7.4