flang-compiler / f18-llvm-project

Fork of llvm/llvm-project for f18. In sync with f18-mlir and f18.
http://llvm.org
28 stars 16 forks source link

A restricted expression may contain object designators whose base object is a dummy with INTENT(OUT) when they occur in specification inquiries #1599

Open rofirrim opened 2 years ago

rofirrim commented 2 years ago

(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.

Screenshot from 2022-05-02 11-44-51

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

Screenshot from 2022-05-02 11-45-39

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

Screenshot from 2022-05-02 11-49-02