-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[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
[flang] Silence spurious error #128777
Conversation
When checking for conflicts between type-bound generic defined I/O procedures and non-type-bound defined I/O generic interfaces, don't worry about conflicts where the type-bound generic interface is inaccessible in the scope around the non-type-bound interface. Fixes llvm#126797.
@llvm/pr-subscribers-flang-semantics Author: Peter Klausler (klausler) ChangesWhen checking for conflicts between type-bound generic defined I/O procedures and non-type-bound defined I/O generic interfaces, don't worry about conflicts where the type-bound generic interface is inaccessible in the scope around the non-type-bound interface. Fixes #126797. Full diff: https://github.com/llvm/llvm-project/pull/128777.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index bf4dc16a15b4a..7b84e8f11cb50 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -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)) {
diff --git a/flang/test/Semantics/io11.f90 b/flang/test/Semantics/io11.f90
index 9b5ad1b8427d9..67f95b8cf64e3 100644
--- a/flang/test/Semantics/io11.f90
+++ b/flang/test/Semantics/io11.f90
@@ -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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks for fixing it.
When checking for conflicts between type-bound generic defined I/O procedures and non-type-bound defined I/O generic interfaces, don't worry about conflicts where the type-bound generic interface is inaccessible in the scope around the non-type-bound interface. Fixes llvm#126797.
When checking for conflicts between type-bound generic defined I/O procedures and non-type-bound defined I/O generic interfaces, don't worry about conflicts where the type-bound generic interface is inaccessible in the scope around the non-type-bound interface.
Fixes #126797.