Skip to content

[flang] Don't flag CLASS(*) ASSOCIATED() pointer or target as error #125890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025
Merged
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
@@ -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
@@ -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 {
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