1 // RUN: tco %s | FileCheck %s
2 // RUN: %flang_fc1 -emit-llvm %s -o - | FileCheck %s
4 // Test of building and passing boxchar.
6 func.func private @callee(%x : !fir.boxchar<1>)
8 // CHECK-LABEL: define void @get_name
9 func.func @get_name() {
10 %1 = fir.address_of (@name) : !fir.ref<!fir.char<1,9>>
11 %2 = arith.constant 9 : i64
12 %3 = fir.convert %1 : (!fir.ref<!fir.char<1,9>>) -> !fir.ref<!fir.char<1,?>>
13 %4 = fir.emboxchar %3, %2 : (!fir.ref<!fir.char<1,?>>, i64) -> !fir.boxchar<1>
14 // CHECK: call void @callee(ptr @name, i64 9)
15 fir.call @callee(%4) : (!fir.boxchar<1>) -> ()
19 // CHECK-LABEL: define void @get_name_2
20 func.func @get_name_2() {
21 %1 = fir.address_of (@name) : !fir.ref<!fir.char<1,9>>
22 %2 = arith.constant 9 : i64
23 %4 = fir.emboxchar %1, %2 : (!fir.ref<!fir.char<1,9>>, i64) -> !fir.boxchar<1>
24 // CHECK: call void @callee(ptr @name, i64 9)
25 fir.call @callee(%4) : (!fir.boxchar<1>) -> ()
29 fir.global @name constant : !fir.char<1,9> {
30 %str = fir.string_lit "Your name"(9) : !fir.char<1,9>
32 fir.has_value %str : !fir.char<1,9>