[flang-commits] [flang] [flang] Silence spurious error (PR #128777)
via flang-commits
flang-commits at lists.llvm.org
Tue Feb 25 13:56:01 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
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 https://github.com/llvm/llvm-project/issues/126797.
---
Full diff: https://github.com/llvm/llvm-project/pull/128777.diff
2 Files Affected:
- (modified) flang/lib/Semantics/check-declarations.cpp (+4-3)
- (modified) flang/test/Semantics/io11.f90 (+31)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/128777
More information about the flang-commits
mailing list