From 6164d363e3d99442f7f1fd81d11b97e979684e2f Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Wed, 5 Apr 2023 13:34:23 -0700 Subject: [PATCH] [flang] Keep the extended value for assumed-type optional Keep the extended value when lowering optional assumed type dummy argument. The extended value is needed to lower correctly the rest of the code. Reviewed By: PeteSteinfeld, jeanPerier Differential Revision: https://reviews.llvm.org/D147575 --- flang/lib/Lower/ConvertExpr.cpp | 3 ++- flang/test/Lower/assumed-type.f90 | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp index c06fcc2..f6a6e70 100644 --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -1844,7 +1844,8 @@ public: const Fortran::evaluate::Symbol *assumedTypeSym = arg.value()->GetAssumedTypeDummy(); auto symBox = symMap.lookupSymbol(*assumedTypeSym); - operands.emplace_back(symBox.getAddr()); + operands.emplace_back( + converter.getSymbolExtendedValue(*assumedTypeSym, &symMap)); continue; } if (!expr) { diff --git a/flang/test/Lower/assumed-type.f90 b/flang/test/Lower/assumed-type.f90 index 856129d..c050779 100644 --- a/flang/test/Lower/assumed-type.f90 +++ b/flang/test/Lower/assumed-type.f90 @@ -48,4 +48,14 @@ contains ! CHECK-SAME: %[[ARG0:.*]]: !fir.box> {fir.bindc_name = "a", fir.optional}) { ! CHECK: %{{.*}} = fir.is_present %[[ARG0]] : (!fir.box>) -> i1 + subroutine assumed_type_lbound(a) + type(*), optional :: a(:,:) + print*,lbound(a,dim=1) + end subroutine + +! CHECK-LABEL: func.func @_QMassumed_type_testPassumed_type_lbound( +! CHECK-SAME: %[[ARG0:.*]]: !fir.box> {fir.bindc_name = "a", fir.optional}) { +! CHECK: %[[C1:.*]] = arith.constant 1 : i32 +! CHECK: %{{.*}} = fir.call @_FortranAioOutputInteger32(%{{.*}}, %[[C1]]) {{.*}} : (!fir.ref, i32) -> i1 + end module -- 2.7.4