[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
Mon Apr 27 05:57:16 PDT 2026
================
@@ -74,3 +74,82 @@ 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
+ end type t2
+end module
+subroutine test_recursive_io_module
+ use m_recursive
+ type(t2) :: obj
+ print *, obj
+end subroutine
+
+! Positive cases: a recursive type is legal when the recursive component
----------------
eugeneepshteyn wrote:
I wanted to have some known good tests here to ensure that nothing got broken. I'm not sure if I need to check for "not failed" or just leave them as is.
https://github.com/llvm/llvm-project/pull/194284
More information about the flang-commits
mailing list