Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion flang/lib/Semantics/check-call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,8 @@ static void CheckAssociated(evaluate::ActualArguments &arguments,
}
if (const auto &targetArg{arguments[1]}) {
// The standard requires that the TARGET= argument, when present,
// be type compatible with the POINTER= for a data pointer. In
// the case of procedure pointers, the standard requires that it
// be a valid RHS for a pointer assignment that has the POINTER=
// argument as its LHS. Some popular compilers misinterpret this
// requirement more strongly than necessary, and actually validate
Expand Down Expand Up @@ -1584,7 +1586,8 @@ static void CheckAssociated(evaluate::ActualArguments &arguments,
}
if (const auto pointerType{pointerArg->GetType()}) {
if (const auto targetType{targetArg->GetType()}) {
ok = pointerType->IsTkCompatibleWith(*targetType);
ok = pointerType->IsTkCompatibleWith(*targetType) ||
targetType->IsTkCompatibleWith(*pointerType);
}
}
} else {
Expand Down
15 changes: 15 additions & 0 deletions flang/test/Semantics/bug125774.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
type t
end type
real, pointer :: rptr
type(t), pointer :: tptr
class(*), pointer :: ulpp
print *, associated(rptr, ulpp)
print *, associated(ulpp, rptr)
print *, associated(tptr, ulpp)
print *, associated(ulpp, tptr)
!ERROR: Arguments of ASSOCIATED() must be a pointer and an optional valid target
print *, associated(rptr, tptr)
!ERROR: Arguments of ASSOCIATED() must be a pointer and an optional valid target
print *, associated(tptr, rptr)
end