| 1 |
! Test interface that lowering handles small interface mismatch with |
| 2 |
! type bound procedures. |
| 3 |
! RUN: bbc -emit-hlfir %s -o - -I nw | FileCheck %s |
| 4 |
|
| 5 |
module dispatch_mismatch |
| 6 |
type t |
| 7 |
integer :: i |
| 8 |
end type |
| 9 |
type, extends(t) :: t2 |
| 10 |
contains |
| 11 |
procedure :: proc => foo |
| 12 |
end type |
| 13 |
|
| 14 |
interface |
| 15 |
subroutine foo(x) |
| 16 |
import :: t2 |
| 17 |
class(t2) :: x |
| 18 |
end subroutine |
| 19 |
end interface |
| 20 |
|
| 21 |
end module |
| 22 |
|
| 23 |
subroutine foo(x) |
| 24 |
use dispatch_mismatch, only : t |
| 25 |
! mistmatch compared to the interface, but OK from an ABI |
| 26 |
! point of view, and OKI because args compatible with t2 are |
| 27 |
! compatible with t. |
| 28 |
class(t) :: x |
| 29 |
end subroutine |
| 30 |
|
| 31 |
subroutine test(x) |
| 32 |
use dispatch_mismatch, only : t2 |
| 33 |
class(t2) :: x |
| 34 |
call x%proc() |
| 35 |
end subroutine |
| 36 |
!CHECK-LABEL: func.func @_QPtest( |
| 37 |
!CHECK: %[[X:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFtestEx"} |
| 38 |
!CHECK: %[[CAST:.*]] = fir.convert %[[X]]#0 : (!fir.class<!fir.type<_QMdispatch_mismatchTt2{t:!fir.type<_QMdispatch_mismatchTt{i:i32}>}>>) -> !fir.class<!fir.type<_QMdispatch_mismatchTt{i:i32}>> |
| 39 |
!CHECK: fir.dispatch "proc"(%[[X]]#0 : !fir.class<!fir.type<_QMdispatch_mismatchTt2{t:!fir.type<_QMdispatch_mismatchTt{i:i32}>}>>) (%[[CAST]] : !fir.class<!fir.type<_QMdispatch_mismatchTt{i:i32}>>) {pass_arg_pos = 0 : i32} |