[PATCH] D87411: [flang] Fix analyzed form of type-bound assignment
Tim Keith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 12:54:26 PDT 2020
tskeith created this revision.
tskeith added reviewers: klausler, PeteSteinfeld, sscalpone.
tskeith added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
tskeith requested review of this revision.
In the analyzed form of type-bound assignment, the binding name was
used where it should have been the subprogram name.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87411
Files:
flang/lib/Semantics/expression.cpp
flang/test/Parser/defined-ops.f90
Index: flang/test/Parser/defined-ops.f90
===================================================================
--- /dev/null
+++ flang/test/Parser/defined-ops.f90
@@ -0,0 +1,29 @@
+! RUN: %f18 -funparse %s 2>&1 | FileCheck %s
+
+! Check that the analyzed form of a type-bound defined operator or assignment
+! uses the resolved subprogram.
+
+module m
+ type :: t
+ contains
+ procedure :: assign
+ procedure :: add
+ generic :: assignment(=) => assign
+ generic :: operator(+) => add
+ end type
+contains
+ subroutine assign(x, y)
+ class(t), intent(out) :: x
+ class(t), intent(in) :: y
+ end
+ type(t) pure function add(x, y)
+ class(t), intent(in) :: x
+ integer, intent(in) :: y
+ end
+end
+
+use m
+type(t) :: x, y
+!CHECK: CALL assign(x,add(y,1_4))
+x = y + 1
+end
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -2946,6 +2946,9 @@
}
}
if (proc) {
+ if (const auto *binding{proc->detailsIf<semantics::ProcBindingDetails>()}) {
+ proc = &binding->symbol();
+ }
ActualArguments actualsCopy{actuals_};
actualsCopy[1]->Parenthesize();
return ProcedureRef{ProcedureDesignator{*proc}, std::move(actualsCopy)};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87411.290807.patch
Type: text/x-patch
Size: 1320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200909/f322cb6a/attachment.bin>
More information about the llvm-commits
mailing list