[flang-commits] [PATCH] D139145: [flang] More error checking for ASSOCIATED()
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Dec 1 14:21:27 PST 2022
klausler created this revision.
klausler added a reviewer: clementval.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
The TARGET= argument of the ASSOCIATED() intrinsic function must be a valid
pointer assignment statement target. Ensure that it does not contain a vector
subscript or any coindexing, either of which would imply a data copy into
temporary storage.
https://reviews.llvm.org/D139145
Files:
flang/lib/Evaluate/intrinsics.cpp
flang/test/Semantics/associated.f90
Index: flang/test/Semantics/associated.f90
===================================================================
--- flang/test/Semantics/associated.f90
+++ flang/test/Semantics/associated.f90
@@ -73,6 +73,9 @@
type(t1), target :: t1xtarget
type(t2) :: t2x
type(t2), target :: t2xtarget
+ integer, target :: targetIntArr(2)
+ integer, target :: targetIntCoarray[*]
+ integer, pointer :: intPointerArr(:)
!ERROR: missing mandatory 'pointer=' argument
lVar = associated()
@@ -177,5 +180,9 @@
cannotBeCalledfromImplicitPointer => externalProc
!WARNING: Procedure pointer 'cannotbecalledfromimplicitpointer' with explicit interface that cannot be called via an implicit interface cannot be associated with procedure designator with an implicit interface
lvar = associated(cannotBeCalledfromImplicitPointer, externalProc)
+ !ERROR: TARGET= argument 'targetintarr([INTEGER(8)::2_8,1_8])' may not have a vector subscript or coindexing
+ lvar = associated(intPointerArr, targetIntArr([2,1]))
+ !ERROR: TARGET= argument 'targetintcoarray[1_8]' may not have a vector subscript or coindexing
+ lvar = associated(intPointerVar1, targetIntCoarray[1])
end subroutine test
end subroutine assoc
Index: flang/lib/Evaluate/intrinsics.cpp
===================================================================
--- flang/lib/Evaluate/intrinsics.cpp
+++ flang/lib/Evaluate/intrinsics.cpp
@@ -2631,8 +2631,8 @@
*targetProcDesignator, context);
targetName = targetProcDesignator->GetName();
} else if (targetSymbol) {
- // proc that's not a call
if (IsProcedure(*targetSymbol)) {
+ // proc that's not a call
targetProc = characteristics::Procedure::Characterize(
*targetSymbol, context);
}
@@ -2693,6 +2693,11 @@
for (SymbolRef ref : symbols) {
msg = AttachDeclaration(msg, *ref);
}
+ } else if (HasVectorSubscript(*targetExpr) ||
+ ExtractCoarrayRef(*targetExpr)) {
+ context.messages().Say(targetArg->sourceLocation(),
+ "TARGET= argument '%s' may not have a vector subscript or coindexing"_err_en_US,
+ targetExpr->AsFortran());
}
if (const auto pointerType{pointerArg->GetType()}) {
if (const auto targetType{targetArg->GetType()}) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139145.479428.patch
Type: text/x-patch
Size: 2543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221201/2b0a66bf/attachment-0001.bin>
More information about the flang-commits
mailing list