f18-llvm-project
f18-llvm-project copied to clipboard
A restricted expression may contain object designators whose base object is a dummy with INTENT(OUT) when they occur in specification inquiries
(Sorry again for the wordy title)
flang is rejecting the following code
module my_mod
contains
subroutine my_sub(str)
implicit none
character(len=*), intent(out) :: str
character(len=1,kind=1), dimension(1:len(str)+1), target :: array_of_char
end subroutine my_sub
end module my_mod
error: Semantic errors in t.f90
./t.f90:8:65: error: Invalid specification expression: reference to INTENT(OUT) dummy argument 'str'
character(len=1,kind=1), dimension(1:len(str)+1), target :: array_of_char
^^^^^^^^^^^^^
A quick read to C1010 (§10.1.11 in Fortran 2018 draft) suggests that this should be rejected due to 10.1.11p2 (2), so flang seems correct. However, all other compilers I've been able to test accept this.

If we keep reading, there is 10.1.11p2 (7)

"Specification inquiry" is defined at 10.1.11p4 and 10.1.11p4 (1) should cover the invocation to LEN.
