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

    <tr>
        <th>Summary</th>
        <td>
            [Flang,OpenMP] optional arguments not working inside OpenMP
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          lukasm91
      </td>
    </tr>
</table>

<pre>
    This code:

```
subroutine s(opt_arg)
implicit none
integer, optional, intent(in) :: opt_arg
integer :: i, ni

ni = 100

!$omp parallel do
do i = 1, ni
  if (present(opt_arg)) then
  endif
enddo
!$omp end parallel do
end subroutine
```

is not working and gives:

```
error: Semantic errors in /app/example.f90
/app/example.f90:10:15: error: Argument of PRESENT() must be the name of a whole OPTIONAL dummy argument
 if (present(opt_arg)) then
                ^^^^^^^
```
when compiled with -fopenmp


https://godbolt.org/z/e6GfcjWcb
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMk99vozgQx_8a8zJqZMyPwAMPuaacTrprq2ulfVwZPIBbY1vYNNv961cmpE12o9Uiy-AZz3fGHzPcOdlrxIpkf5FsH_HZD2aq1PzK3VjGUWPEe_U8SAetEUiSHaF7Qk9zTtexLN3cTGb2UiM4wgpj_Vc-9YSVR7ccrZKt9KCNxtWkPfY4EXYLxnppNFfhO5i1J6yQmrASQtZkBye988iTT4YwLc-L0xJIsoeY0ouSWUxYakYLlk9cKVQgzNElDKwh52IAsgPCCjuhOxZ1di5Wgh9Qn3aiFrI7LlCLk-5nStTi17TB-EnuKtj1yA608XAw06vUPXAtoJdv6H5_KThNZgqInnDk2ssWFosDqYGwmltLWI3f-GgVbrrylPGaJ9nFy5QFuQ_d3dTPI2oPpoPH_--e7u6fCSsCmnF2HhoMiEDzEcMODofBKISHx-d_Hu53_4KYx_Ed-Cqykvxz5JcPye6ujGtYDgNqaM1opUIBB-kHuOmMRT3aC5jLPHhvF8ysJqzujWiM8hsTCqq_B0j531378qVtIlElokxKHmEVb1mSp2laxNFQlUlZdJiXnBZIU46sLHJsiq7NBS_zjEayYpSltIjTOKUFjTfZFrdpJvi2yJIMW0pSiiOXaqPU2xhyR9K5GauYJmWRR4o3qNzSxYx1iuueMBYaeqpCwE0z946kVEnn3aeEl14trV8fI24fLOr_Hkm2_-jHj6u5_PukdlIgHPdH86SqnyBJP8zNpjUjYXXIt75u7GResPWE1Uv9jrB6PcJbxX4EAAD__wqZWRM">