diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -1565,6 +1565,12 @@ msg = "In defined assignment subroutine '%s', second dummy" " argument '%s' must have INTENT(IN) or VALUE attribute"_err_en_US; + } else if (dataObject->attrs.test(DummyDataObject::Attr::Pointer)) { + msg = + "In defined assignment subroutine '%s', second dummy argument '%s' must not be a pointer"_err_en_US; + } else if (dataObject->attrs.test(DummyDataObject::Attr::Allocatable)) { + msg = + "In defined assignment subroutine '%s', second dummy argument '%s' must not be an allocatable"_err_en_US; } } else { DIE("pos must be 0 or 1"); diff --git a/flang/test/Semantics/resolve65.f90 b/flang/test/Semantics/resolve65.f90 --- a/flang/test/Semantics/resolve65.f90 +++ b/flang/test/Semantics/resolve65.f90 @@ -65,6 +65,18 @@ end end interface end + !ERROR: In defined assignment subroutine 's3', second dummy argument 'y' must not be a pointer + subroutine s3(x, y) + import t + type(t), intent(out) :: x + type(t), intent(in), pointer :: y + end + !ERROR: In defined assignment subroutine 's4', second dummy argument 'y' must not be an allocatable + subroutine s4(x, y) + import t + type(t), intent(out) :: x + type(t), intent(in), allocatable :: y + end end interface end