diff --git a/flang/test/Fir/embox.fir b/flang/test/Fir/embox.fir --- a/flang/test/Fir/embox.fir +++ b/flang/test/Fir/embox.fir @@ -61,6 +61,29 @@ return } +func.func private @takesRank2CharBox(!fir.box>>) + +// CHECK-LABEL: define void @emboxSubstring( +// CHECK-SAME: ptr %[[arg0:.*]]) +func.func @emboxSubstring(%arg0: !fir.ref>>) { + %c2 = arith.constant 2 : index + %c3 = arith.constant 3 : index + %c1 = arith.constant 1 : index + %c1_i64 = arith.constant 1 : i64 + %c2_i64 = arith.constant 2 : i64 + %0 = fir.shape %c2, %c3 : (index, index) -> !fir.shape<2> + %1 = fir.slice %c1, %c2, %c1, %c1, %c3, %c1 substr %c1_i64, %c2_i64 : (index, index, index, index, index, index, i64, i64) -> !fir.slice<2> + %2 = fir.embox %arg0(%0) [%1] : (!fir.ref>>, !fir.shape<2>, !fir.slice<2>) -> !fir.box>> + // CHECK: %[[addr:.*]] = getelementptr [3 x [2 x [4 x i8]]], ptr %[[arg0]], i64 0, i64 0, i64 0 + // CHECK: %[[substringAddr:.*]] = getelementptr {{.*}}, ptr %[[addr]], i64 0, i64 1 + // CHECK: insertvalue {[[descriptorType:.*]]} { ptr undef, i64 2, i32 20180515, i8 2, i8 40, i8 0, i8 0, + // CHECK-SAME: [2 x [3 x i64]] [{{\[}}3 x i64] [i64 1, i64 2, i64 4], [3 x i64] [i64 1, i64 3, i64 8]] }, + // CHECK-SAME: ptr %[[substringAddr]], 0 + + fir.call @takesRank2CharBox(%2) : (!fir.box>>) -> () + return +} + func.func private @do_something(!fir.box>) -> () // CHECK: define void @fir_dev_issue_1416 // CHECK-SAME: ptr %[[base_addr:.*]], i64 %[[low:.*]], i64 %[[up:.*]], i64 %[[at:.*]])