Skip to content

Commit

Permalink
[flang] lower assumed type actual arguments in call statements
Browse files Browse the repository at this point in the history
  • Loading branch information
cabreraam committed Apr 26, 2024
1 parent 1728a56 commit 6986087
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions flang/test/HLFIR/assumed-type-actual-arguments.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
! Test lowering of call statements to HLFIR with assumed types
! arguments. These are a bit special because semantics do not represent
! assumed types actual arguments with an evaluate::Expr like for usual
! arguments.
! RUN: bbc -emit-hlfir --polymorphic-type -o - %s | FileCheck %s

subroutine test1(x)
type(*) :: x
interface
subroutine fun1(x)
type(*) :: x
end subroutine
end interface
call fun1(x)
end subroutine
! CHECK-LABEL: func.func @_QPtest1(
! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<none> {fir.bindc_name = "x"}) {
! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFtest1Ex"} : (!fir.ref<none>) -> (!fir.ref<none>, !fir.ref<none>)
! CHECK: fir.call @_QPfun1(%[[VAL_0]]#1) fastmath<contract> : (!fir.ref<none>) -> ()
! CHECK: return
! CHECK: }

subroutine test2(x)
type(*) :: x
interface
subroutine fun2(x)
type(*) :: x(:)
end subroutine
end interface
call fun2(x)
end subroutine
! CHECK-LABEL: func.func @_QPtest2(
! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<none> {fir.bindc_name = "x"}) {
! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFtest2Ex"} : (!fir.ref<none>) -> (!fir.ref<none>, !fir.ref<none>)
! CHECK: %[[VAL_1:.*]] = fir.embox %[[VAL_0]]#0 : (!fir.ref<none>) -> !fir.box<none>
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.box<none>) -> !fir.box<!fir.array<?xnone>>
! CHECK: fir.call @_QPfun2(%[[VAL_2]]) fastmath<contract> : (!fir.box<!fir.array<?xnone>>) -> ()
! CHECK: return
! CHECK: }

0 comments on commit 6986087

Please sign in to comment.