From 6986087c2982a7aea8bad104987bc910845fac2f Mon Sep 17 00:00:00 2001 From: cabreraam Date: Tue, 19 Dec 2023 15:51:17 -0500 Subject: [PATCH] [flang] lower assumed type actual arguments in call statements --- .../HLFIR/assumed-type-actual-arguments.f90 | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 flang/test/HLFIR/assumed-type-actual-arguments.f90 diff --git a/flang/test/HLFIR/assumed-type-actual-arguments.f90 b/flang/test/HLFIR/assumed-type-actual-arguments.f90 new file mode 100644 index 00000000000000..716dc2dbb39493 --- /dev/null +++ b/flang/test/HLFIR/assumed-type-actual-arguments.f90 @@ -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 {fir.bindc_name = "x"}) { +! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFtest1Ex"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: fir.call @_QPfun1(%[[VAL_0]]#1) fastmath : (!fir.ref) -> () +! 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 {fir.bindc_name = "x"}) { +! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFtest2Ex"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[VAL_1:.*]] = fir.embox %[[VAL_0]]#0 : (!fir.ref) -> !fir.box +! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.box) -> !fir.box> +! CHECK: fir.call @_QPfun2(%[[VAL_2]]) fastmath : (!fir.box>) -> () +! CHECK: return +! CHECK: } \ No newline at end of file