[flang][hlfir] Map scalar character symbols in internal procedures
authorJean Perier <jperier@nvidia.com>
Tue, 7 Mar 2023 07:59:57 +0000 (08:59 +0100)
committerJean Perier <jperier@nvidia.com>
Tue, 7 Mar 2023 08:00:15 +0000 (09:00 +0100)
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
flang/test/Lower/HLFIR/internal-procedures.f90

index 4d8a120172eff42cfb6a7f92be7de914053bcaf8..008e4fc5c9a0e741dd059bb576ab65bc95cdc451 100644 (file)
@@ -243,7 +243,9 @@ public:
                                                args.loc);
     std::pair<mlir::Value, mlir::Value> unboxchar =
         charHelp.createUnboxChar(args.valueInTuple);
-    args.symMap.addCharSymbol(sym, unboxchar.first, unboxchar.second);
+    bindCapturedSymbol(sym,
+                       fir::CharBoxValue{unboxchar.first, unboxchar.second},
+                       converter, args.symMap);
   }
 };
 
index 4ad272ed4900d822d35c75bf52a4c5e6faf1ae31..ca3ec3e74289baa1f327eee9fd1ed8e3d2082334 100644 (file)
@@ -36,3 +36,19 @@ end subroutine
 ! CHECK:  %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_4]] : (!fir.box<!fir.array<?xf32>>, 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.array<?xf32>>, !fir.shift<1>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+
+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<tuple<!fir.boxchar<1>>> {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<tuple<!fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
+! CHECK:  %[[VAL_3:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.boxchar<1>>
+! CHECK:  %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_3]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK:  %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]]#0 typeparams %[[VAL_4]]#1 {uniq_name = "_QFtest_scalar_charEc"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
+! CHECK:  fir.call @_QPbar(%[[VAL_5]]#0) {{.*}}: (!fir.boxchar<1>) -> ()