[PATCH] D120749: [flang] Fix result type of "procedure(abs) :: f"
Peter Klausler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 2 11:11:58 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e082a4a9c2d: [flang] Fix result type of "procedure(abs) :: f" (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120749/new/
https://reviews.llvm.org/D120749
Files:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/procinterface01.f90
Index: flang/test/Semantics/procinterface01.f90
===================================================================
--- flang/test/Semantics/procinterface01.f90
+++ flang/test/Semantics/procinterface01.f90
@@ -53,13 +53,13 @@
!DEF: /module1/derived1/p5 NOPASS, POINTER (Function) ProcEntity COMPLEX(4)
!DEF: /module1/nested4 PUBLIC (Function) Subprogram COMPLEX(4)
procedure(complex), pointer, nopass :: p5 => nested4
- !DEF: /module1/sin ELEMENTAL, INTRINSIC, PUBLIC, PURE (Function) ProcEntity
- !DEF: /module1/derived1/p6 NOPASS, POINTER (Function) ProcEntity
+ !DEF: /module1/sin ELEMENTAL, INTRINSIC, PUBLIC, PURE (Function) ProcEntity REAL(4)
+ !DEF: /module1/derived1/p6 NOPASS, POINTER (Function) ProcEntity REAL(4)
!REF: /module1/nested1
procedure(sin), pointer, nopass :: p6 => nested1
!REF: /module1/sin
- !DEF: /module1/derived1/p7 NOPASS, POINTER (Function) ProcEntity
- !DEF: /module1/cos ELEMENTAL, INTRINSIC, PUBLIC, PURE (Function) ProcEntity
+ !DEF: /module1/derived1/p7 NOPASS, POINTER (Function) ProcEntity REAL(4)
+ !DEF: /module1/cos ELEMENTAL, INTRINSIC, PUBLIC, PURE (Function) ProcEntity REAL(4)
procedure(sin), pointer, nopass :: p7 => cos
!REF: /module1/tan
!DEF: /module1/derived1/p8 NOPASS, POINTER (Function) ProcEntity CHARACTER(1_4,1)
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -5124,10 +5124,24 @@
if (auto interface{context().intrinsics().IsSpecificIntrinsicFunction(
name.source.ToString())}) {
// Unrestricted specific intrinsic function names (e.g., "cos")
- // are acceptable as procedure interfaces.
+ // are acceptable as procedure interfaces. The presence of the
+ // INTRINSIC flag will cause this symbol to have a complete interface
+ // recreated for it later on demand, but capturing its result type here
+ // will make GetType() return a correct result without having to
+ // probe the intrinsics table again.
Symbol &symbol{
MakeSymbol(InclusiveScope(), name.source, Attrs{Attr::INTRINSIC})};
- symbol.set_details(ProcEntityDetails{});
+ CHECK(interface->functionResult.has_value());
+ evaluate::DynamicType dyType{
+ DEREF(interface->functionResult->GetTypeAndShape()).type()};
+ CHECK(common::IsNumericTypeCategory(dyType.category()));
+ const DeclTypeSpec &typeSpec{
+ MakeNumericType(dyType.category(), dyType.kind())};
+ ProcEntityDetails details;
+ ProcInterface procInterface;
+ procInterface.set_type(typeSpec);
+ details.set_interface(procInterface);
+ symbol.set_details(std::move(details));
symbol.set(Symbol::Flag::Function);
if (interface->IsElemental()) {
symbol.attrs().set(Attr::ELEMENTAL);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120749.412490.patch
Type: text/x-patch
Size: 2859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220302/00f0f33b/attachment.bin>
More information about the llvm-commits
mailing list