diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -917,13 +917,6 @@ std::string name = converter.mangleName(*symbol); mlir::func::FuncOp func = Fortran::lower::getOrDeclareFunction(name, proc, converter); - // Abstract results require later rewrite of the function type. - // This currently does not happen inside GloalOps, causing LLVM - // IR verification failure. This helper is only here to catch these - // cases and emit a TODOs for now. - if (inInitializer && fir::hasAbstractResult(func.getFunctionType())) - TODO(converter.genLocation(symbol->name()), - "static description of non trivial procedure bindings"); funcPtr = builder.create(loc, func.getFunctionType(), builder.getSymbolRefAttr(name)); } diff --git a/flang/test/Fir/non-trivial-procedure-binding-description.f90 b/flang/test/Fir/non-trivial-procedure-binding-description.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Fir/non-trivial-procedure-binding-description.f90 @@ -0,0 +1,30 @@ +! RUN: %flang_fc1 -emit-mlir %s -o - | FileCheck %s --check-prefix=BEFORE +! RUN: %flang_fc1 -emit-mlir %s -o - | fir-opt --abstract-result-on-global-opt | FileCheck %s --check-prefix=AFTER +module a + type f + contains +! BEFORE: fir.address_of(@_QMaPfoo) : (!fir.ref>) -> !fir.box>> +! AFTER: [[ADDRESS:%.*]] = fir.address_of(@_QMaPfoo) : (!fir.ref>>>, !fir.ref>) -> () +! AFTER: fir.convert [[ADDRESS]] : ((!fir.ref>>>, !fir.ref>) -> ()) -> ((!fir.ref>) -> !fir.box>>) +! AFTER-NOT: fir.address_of(@_QMaPfoo) : (!fir.ref>) -> !fir.box>> + procedure, nopass :: foo + end type f +contains + function foo(obj) result(bar) + type(f) :: obj + character(len=:), allocatable :: bar + + if (.TRUE.) then + bar = "true" + else + bar = "false" + endif + end function foo +end module a + +program main + use a + + type(f) :: obj + print *, obj%foo(obj) +end program