[flang-commits] [PATCH] D119845: [flang] Accept pointer assignment w/ remapping to function result
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Feb 15 09:39:57 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7763c0140148: [flang] Accept pointer assignment w/ remapping to function result (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/D119845/new/
https://reviews.llvm.org/D119845
Files:
flang/include/flang/Evaluate/characteristics.h
flang/lib/Evaluate/characteristics.cpp
flang/lib/Semantics/pointer-assignment.cpp
flang/test/Semantics/assign03.f90
Index: flang/test/Semantics/assign03.f90
===================================================================
--- flang/test/Semantics/assign03.f90
+++ flang/test/Semantics/assign03.f90
@@ -218,6 +218,13 @@
p(1:5,1:5) => x(:,1:2)
!OK - rhs has rank 1 and enough elements
p(1:5,1:5) => y(1:100:2)
+ !OK - same, but from function result
+ p(1:5,1:5) => f()
+ contains
+ function f()
+ real, pointer :: f(:)
+ f => y
+ end function
end
subroutine s10
Index: flang/lib/Semantics/pointer-assignment.cpp
===================================================================
--- flang/lib/Semantics/pointer-assignment.cpp
+++ flang/lib/Semantics/pointer-assignment.cpp
@@ -172,7 +172,8 @@
const auto *frTypeAndShape{funcResult->GetTypeAndShape()};
CHECK(frTypeAndShape);
if (!lhsType_->IsCompatibleWith(context_.messages(), *frTypeAndShape,
- "pointer", "function result", false /*elemental*/,
+ "pointer", "function result",
+ isBoundsRemapping_ /*omit shape check*/,
evaluate::CheckConformanceFlags::BothDeferredShape)) {
return false; // IsCompatibleWith() emitted message
}
Index: flang/lib/Evaluate/characteristics.cpp
===================================================================
--- flang/lib/Evaluate/characteristics.cpp
+++ flang/lib/Evaluate/characteristics.cpp
@@ -149,14 +149,15 @@
bool TypeAndShape::IsCompatibleWith(parser::ContextualMessages &messages,
const TypeAndShape &that, const char *thisIs, const char *thatIs,
- bool isElemental, enum CheckConformanceFlags::Flags flags) const {
+ bool omitShapeConformanceCheck,
+ enum CheckConformanceFlags::Flags flags) const {
if (!type_.IsTkCompatibleWith(that.type_)) {
messages.Say(
"%1$s type '%2$s' is not compatible with %3$s type '%4$s'"_err_en_US,
thatIs, that.AsFortran(), thisIs, AsFortran());
return false;
}
- return isElemental ||
+ return omitShapeConformanceCheck ||
CheckConformance(messages, shape_, that.shape_, flags, thisIs, thatIs)
.value_or(true /*fail only when nonconformance is known now*/);
}
Index: flang/include/flang/Evaluate/characteristics.h
===================================================================
--- flang/include/flang/Evaluate/characteristics.h
+++ flang/include/flang/Evaluate/characteristics.h
@@ -147,7 +147,7 @@
int Rank() const { return GetRank(shape_); }
bool IsCompatibleWith(parser::ContextualMessages &, const TypeAndShape &that,
const char *thisIs = "pointer", const char *thatIs = "target",
- bool isElemental = false,
+ bool omitShapeConformanceCheck = false,
enum CheckConformanceFlags::Flags = CheckConformanceFlags::None) const;
std::optional<Expr<SubscriptInteger>> MeasureElementSizeInBytes(
FoldingContext &, bool align) const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119845.408931.patch
Type: text/x-patch
Size: 2882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220215/f9705232/attachment.bin>
More information about the flang-commits
mailing list