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

    <tr>
        <th>Summary</th>
        <td>
            [flang][OpenMP] Missing pre-determined DSA for static duration variables
        </td>
    </tr>

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

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

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

<pre>
    ```
module test_mod
  complex :: tm3a/(0,0)/
contains
  subroutine f4()
    !$omp task
      !$omp task
        tm3a = (1, 2)
      !$omp end task
 !$omp end task
  !$omp taskwait
  print *,tm3a
  end subroutine
end module

program main
  use test_mod
  call f4()
end program
```

```
flang -fopenmp test.f90 -o out && ./out
```

This should print `(1, 2)` not `(0, 0)`. The problem that flang is currently setting `tm3a` to FIRSTPRIVATE.

The relevant section is 7.1.1 of [OpenMP 6.0](https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-6-0.pdf).

There is one rule saying that variables with static storage duration are **predetermined** as SHARED. Another rule for **implicitly determined** DSA, "in a task-generating construct, if no default clause is present, a variable for which the data-sharing attribute is not determined by the rules above is firstprivate".

My interpretation of this is that the rule for predetermined DSA takes precedence and `tm3a` should be SHARED.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0VN2OqzgTfBrnpgUyDeTnggvO5ETfXIy-0cxob1cGmuA9xkZ2k-y8_cqQ-T27UqSIkqu7qiijQtBnS1SJ8ocojxs18-B8xY1Rw6Zx3WsltvL2k_XoutkQMAX-c3SdkDVA68bJ0N8g8lrkNfCYK4EngXsp8E4KPMQnWbfOstI2LJwwN97NrC1BXwjcx1MRBxCYCSzcOAGr8OsG_icMyzoQ-REE7jOBd4Afsz7TyHbv1H9Hv-24Ks0LPHltGQTWAu8WcxGMxA8TQtYRWNMRshaynrw7ezXCqLRdGHP4npsy5rP7OOHGiiM-pf7t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