Skip to content

[flang] Silence bogus error message #111057

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
Oct 7, 2024
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
4 changes: 3 additions & 1 deletion flang/lib/Semantics/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,9 @@ bool HasDefinedIo(common::DefinedIo which, const DerivedTypeSpec &derived,
}
}
}
return false;
// Check for inherited defined I/O
const auto *parentType{derived.typeSymbol().GetParentTypeSpec()};
return parentType && HasDefinedIo(which, *parentType, scope);
}

void WarnOnDeferredLengthCharacterScalar(SemanticsContext &context,
Expand Down
11 changes: 5 additions & 6 deletions flang/test/Semantics/io14.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module m
procedure :: fwrite
generic :: write(formatted) => fwrite
end type
type, extends(t) :: t2
end type
contains
subroutine fwrite(x, unit, iotype, vlist, iostat, iomsg)
class(t), intent(in) :: x
Expand All @@ -19,19 +21,16 @@ subroutine fwrite(x, unit, iotype, vlist, iostat, iomsg)
character(*), intent(in out) :: iomsg
write(unit, *, iostat=iostat, iomsg=iomsg) '(', iotype, ':', vlist, ':', x%n, ')'
end subroutine
subroutine subr(x, y, z)
subroutine subr(x, y, z, w)
class(t), intent(in) :: x
class(base), intent(in) :: y
class(*), intent(in) :: z
class(t2), intent(in) :: w
print *, x ! ok
print *, w ! ok
!ERROR: Derived type 'base' in I/O may not be polymorphic unless using defined I/O
print *, y
!ERROR: I/O list item may not be unlimited polymorphic
print *, z
end subroutine
end

program main
use m
call subr(t(123),t(234),t(345))
end
Loading