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

    <tr>
        <th>Summary</th>
        <td>
            [flang][OpenMP] assertion failure for copyin of common variables
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            crash-on-valid,
            flang:openmp
      </td>
    </tr>

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

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

<pre>
    `flang -fopenmp` currently hits an assertion failure building this program: https://github.com/fujitsu/compiler-test-suite/blob/main/Fortran/0070/0070_0185.f03

```
llvm-project/flang/include/flang/Optimizer/Builder/BoxValue.h:375: fir::MutableBoxValue::MutableBoxValue(mlir::Value, mlir::ValueRange, MutableProperties): Assertion `verify() && "MutableBoxValue requires mem ref to fir.box<fir.[heap|ptr]<type>>"` failed.
```

There are two problems here
1. We should add a semantic check similar to https://github.com/llvm/llvm-project/pull/110671 which prevents namelist variables in copyin. This is already not allowed in private and reduction and it was concluded in the above PR that even if the standard allows this we should not support it because it would be difficult to do without introducing performance regressions
2. The assertion failure (reproducible with the name-list removed)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVFuvozYQ_jXOyygRmECSBx5yTsrbao9Wq_axMngIszW2O7aTTX99ZchetDqqVAmBGV_G32VGhUBXi9iK-kXUl41KcXLcxt6oadM7_WhFU4xG2StsR-fRzl40BQyJGW00D5goBlAWVAjIkZyFUZFJjNAnMprsFeJEATy7K6tZVGeYYvRBVGchOyG7K8Up9bvBzUJ2Y_pCMSQhu8HNngzyNmKI25AoopBdb1wvZDcrskJ2nePIKo-K4lA8P38W5bHejUUliosozs93Uzyf5deY27z17L7gEHPWjE_IjuxgksafIh99pJn-QRaye8l41pH7-rsyCXeTqM7Voc6gRuIMqTp_SFH1Br-teT8oj7P5tuEZeYVfQp-UvS7x5-Y3dj5TjEHIU055_k65aIobMo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