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()}) { 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