<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60226>60226</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] Compilation error of ALLOCATABLE dummy argument
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 16.0.0(77f2f34d696b77fe5bf05afbe7386966b6bcc8ba)
```

ALLOCATABLE dummy argument results in a compilation-time error.

The following are the test program, flang-new, gfortran and ifort compilation result.

snggj331_.f90:
```fortran
program main
  call sub
 print *,'OK'
end program main

module m1
contains
  function func(i,p) result(a)
 character(len=1,kind=1),allocatable,dimension(:,:):: a
 character(len=*,kind=1),allocatable,optional,dimension(:,:)::p
 character(len=*,kind=1),optional,intent(in)::i
  end function func
 function   chk(i,p) result(r)
    logical r(2)
 character(len=*,kind=1),allocatable,optional,dimension(:,:)::p
 character(len=*,kind=1),optional,intent(in)::i
    r=.true.
  end function chk
end module m1

recursive subroutine sub
  use m1
 character(len=1,kind=1),allocatable,dimension(:,:):: pointer
  if (count(mask=chk(p=func(i='1',p=pointer),i='1'))/=2)write(6,*) "NG"
end subroutine sub
```

```
$ flang-new -flang-experimental-exec snggj331_.f90
error: Semantic errors in snggj331_.f90
./snggj331_.f90:24:24: error: ALLOCATABLE dummy argument 'p=' must be associated with an ALLOCATABLE actual argument
    if (count(mask=chk(p=func(i='1',p=pointer),i='1'))/=2)write(6,*) "NG"
 ^^^^^^^^^^^^^^^^^^^^^
$
```

```
$ gfortran snggj331_.f90
$
```

```
$ ifort snggj331_.f90
snggj331_.f90(8): warning #6178: The return value of this FUNCTION has not been defined.   [A]
  function i4_f(i,p) result(a)
----------------------------^
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzM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