[flang-commits] [flang] [flang][Semantics] Break recursion on illegal recursive type in I/O check (PR #194284)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Fri May 1 08:58:50 PDT 2026
================
@@ -74,3 +74,81 @@ subroutine test4(u)
end subroutine
end module
+! Regression test: an illegal recursive derived-type component used to cause
+! infinite recursion in FindUnsafeIoDirectComponent when the object appeared
+! in an I/O list (issue #192387).
+subroutine test_recursive_io
+ type t1
+ !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE
+ type(t1) :: b
+ end type t1
+ type(t1) :: obj
+ print *, obj
+end subroutine
+
+! Same regression covering the FindInaccessibleComponent walk: the type
+! must be defined in a module and used in I/O outside that module so the
+! recursive component traversal in FindInaccessibleComponent is reached.
+module m_recursive
+ type t2
+ !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE
+ type(t2) :: b
----------------
eugeneepshteyn wrote:
I tried to come up with a mutually recursive type test that triggers this error, but the issue is that I can't trigger this code path with it, it errors out (correctly) elsewhere. If I break one of the links, it's no longer a problem, for example:
```
type :: t2
type(t1), pointer :: link => null()
integer :: y
end type
type :: t1
type(t2) :: nested
integer :: x
end type
```
https://github.com/llvm/llvm-project/pull/194284
More information about the flang-commits
mailing list