[flang-commits] [PATCH] D125135: [flang] Reverse a reversed type compatibility check
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri May 6 14:53:35 PDT 2022
klausler created this revision.
klausler added a reviewer: jeanPerier.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
The semantic test for an intrinsic assignment to a polymorphic
derived type entity from a type that is an extension of its base
type was reversed, so it would allow assignments that it shouldn't
and disallowed some that it should; and the test case for it
incorectly assumed that the invalid semantics were correct.
Fix the code and the test, and add a new test for the invalid
case (LHS type is an extension of the RHS type).
https://reviews.llvm.org/D125135
Files:
flang/lib/Semantics/tools.cpp
flang/test/Semantics/selecttype03.f90
Index: flang/test/Semantics/selecttype03.f90
===================================================================
--- flang/test/Semantics/selecttype03.f90
+++ flang/test/Semantics/selecttype03.f90
@@ -110,11 +110,16 @@
if (i>0) then
foo = array1(2,U)
else if (i<0) then
- !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types CLASS(t1) and CLASS(t2)
- foo = array2(2,U)
+ foo = array2(2,U) ! ok: t2 extends t1
end if
end function
+ function foo2()
+ class(t2),DIMENSION(:),allocatable :: foo2
+ !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types CLASS(t2) and CLASS(t1)
+ foo2 = array1(2,:)
+ end function
+
subroutine sub_with_in_and_inout_param(y, z)
type(t2), INTENT(IN) :: y
class(t2), INTENT(INOUT) :: z
Index: flang/lib/Semantics/tools.cpp
===================================================================
--- flang/lib/Semantics/tools.cpp
+++ flang/lib/Semantics/tools.cpp
@@ -94,7 +94,7 @@
static bool MightBeSameDerivedType(
const std::optional<evaluate::DynamicType> &lhsType,
const std::optional<evaluate::DynamicType> &rhsType) {
- return lhsType && rhsType && rhsType->IsTkCompatibleWith(*lhsType);
+ return lhsType && rhsType && lhsType->IsTkCompatibleWith(*rhsType);
}
Tristate IsDefinedAssignment(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125135.427762.patch
Type: text/x-patch
Size: 1340 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220506/d598b237/attachment.bin>
More information about the flang-commits
mailing list