| 1 |
! RUN: bbc -emit-hlfir -o - %s -I nowhere | FileCheck %s |
| 2 |
|
| 3 |
module polymorphic_expressions_types |
| 4 |
type t |
| 5 |
integer c |
| 6 |
end type t |
| 7 |
end module polymorphic_expressions_types |
| 8 |
|
| 9 |
! Test that proper polymorphic type used for hlfir.as_expr, |
| 10 |
! and that hlfir.association has polymorphic result type. |
| 11 |
subroutine test1(a) |
| 12 |
use polymorphic_expressions_types |
| 13 |
interface |
| 14 |
subroutine callee(x) |
| 15 |
use polymorphic_expressions_types |
| 16 |
class(t) :: x(:) |
| 17 |
end subroutine callee |
| 18 |
end interface |
| 19 |
class(t), allocatable :: a |
| 20 |
call callee(spread(a, 1, 2)) |
| 21 |
end subroutine test1 |
| 22 |
! CHECK-LABEL: func.func @_QPtest1( |
| 23 |
! CHECK: %[[VAL_21:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) {uniq_name = ".tmp.intrinsic_result"} : (!fir.class<!fir.heap<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>>, !fir.shift<1>) -> (!fir.class<!fir.heap<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>>, !fir.class<!fir.heap<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>>) |
| 24 |
! CHECK: %[[VAL_22:.*]] = arith.constant true |
| 25 |
! CHECK: %[[VAL_23:.*]] = hlfir.as_expr %[[VAL_21]]#0 move %[[VAL_22]] : (!fir.class<!fir.heap<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>>, i1) -> !hlfir.expr<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>?> |
| 26 |
! CHECK: %[[VAL_24:.*]] = arith.constant 0 : index |
| 27 |
! CHECK: %[[VAL_25:.*]]:3 = fir.box_dims %[[VAL_21]]#0, %[[VAL_24]] : (!fir.class<!fir.heap<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>>, index) -> (index, index, index) |
| 28 |
! CHECK: %[[VAL_26:.*]] = fir.shape %[[VAL_25]]#1 : (index) -> !fir.shape<1> |
| 29 |
! CHECK: %[[VAL_27:.*]]:3 = hlfir.associate %[[VAL_23]](%[[VAL_26]]) {adapt.valuebyref} : (!hlfir.expr<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>?>, !fir.shape<1>) -> (!fir.class<!fir.heap<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>>, !fir.class<!fir.heap<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>>, i1) |
| 30 |
! CHECK: %[[VAL_28:.*]] = fir.rebox %[[VAL_27]]#0 : (!fir.class<!fir.heap<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>>) -> !fir.class<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>> |
| 31 |
! CHECK: fir.call @_QPcallee(%[[VAL_28]]) fastmath<contract> : (!fir.class<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>) -> () |
| 32 |
! CHECK: hlfir.end_associate %[[VAL_27]]#0, %[[VAL_27]]#2 : !fir.class<!fir.heap<!fir.array<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>>>>, i1 |
| 33 |
! CHECK: hlfir.destroy %[[VAL_23]] : !hlfir.expr<?x!fir.type<_QMpolymorphic_expressions_typesTt{c:i32}>?> |