Files
clang-p2996/flang/test/Semantics/call27.f90
Peter Klausler 61d361d69b [flang] Extension: accept NULL([MOLD=]) for ALLOCATABLE INTENT(IN) du… (#66256)
…mmy argument

Several compilers accept a null pointer (with or without a MOLD=) as an
actual argument for association with an INTENT(IN) allocatable dummy
argument. At runtime, the allocatable dummy argument appears to be in
the unallocated state. This seems useful, unambiguous, unlikely to
invalidate conforming code, and works with Intel, NAG, & XLF, so it
should be supported with an optional portability warning in this
compiler as well.
2023-09-18 12:37:46 -07:00

20 lines
635 B
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
! Catch NULL() actual argument association with allocatable dummy argument
program test
!ERROR: NULL() actual argument 'NULL()' may not be associated with allocatable dummy argument 'a=' without INTENT(IN)
call foo1(null())
!PORTABILITY: Allocatable dummy argument 'a=' is associated with NULL()
call foo2(null())
call foo3(null()) ! ok
contains
subroutine foo1(a)
real, allocatable :: a
end subroutine
subroutine foo2(a)
real, allocatable, intent(in) :: a
end subroutine
subroutine foo3(a)
real, allocatable, optional :: a
end subroutine
end