Skip to content

[flang] Silence spurious error #128777

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
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
7 changes: 4 additions & 3 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3336,11 +3336,12 @@ void CheckHelper::CheckAlreadySeenDefinedIo(const DerivedTypeSpec &derivedType,
return;
}
if (const Scope * dtScope{derivedType.scope()}) {
if (auto iter{dtScope->find(generic.name())}; iter != dtScope->end()) {
if (auto iter{dtScope->find(generic.name())}; iter != dtScope->end() &&
IsAccessible(*iter->second, generic.owner())) {
for (auto specRef : iter->second->get<GenericDetails>().specificProcs()) {
const Symbol &specific{specRef->get<ProcBindingDetails>().symbol()};
if (specific == proc) { // unambiguous, accept
continue;
if (specific == proc) {
continue; // unambiguous, accept
}
if (const auto *specDT{GetDtvArgDerivedType(specific)};
specDT && evaluate::AreSameDerivedType(derivedType, *specDT)) {
Expand Down
31 changes: 31 additions & 0 deletions flang/test/Semantics/io11.f90
Original file line number Diff line number Diff line change
Expand Up @@ -689,3 +689,34 @@ module m26b
procedure unformattedRead
end interface
end

module m27a
type t
integer c
contains
procedure ur1
generic, private :: read(unformatted) => ur1
end type
contains
subroutine ur1(dtv,unit,iostat,iomsg)
class(t),intent(inout) :: dtv
integer,intent(in) :: unit
integer,intent(out) :: iostat
character(*),intent(inout) :: iomsg
read(unit,iotype,iostat=iostat,iomsg=iomsg) dtv%c
end
end
module m27b
use m27a
interface read(unformatted)
module procedure ur2 ! ok, t's generic is inaccessible
end interface
contains
subroutine ur2(dtv,unit,iostat,iomsg)
class(t),intent(inout) :: dtv
integer,intent(in) :: unit
integer,intent(out) :: iostat
character(*),intent(inout) :: iomsg
read(unit,iotype,iostat=iostat,iomsg=iomsg) dtv%c
end
end
Loading