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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Flang crashes on invalid OpenMP directive "omp sections parallel"
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    When compiling the following Fortran code with Flang, the compiler crashes.
This code is intentionally invalid and should trigger a syntax error, but instead, Flang crashes.
This reproducer was generated by ChatGPT.
https://godbolt.org/z/s59av95EY
```f90
!$omp sections parallel
!$omp section
    x = x + 1
!$omp end sections
end
```

With assertion-enabled flang, I got the following assertion failure:
```txt
flang: /path_to_project/llvm-project/flang/lib/Lower/OpenMP/Decomposer.cpp:87: Fortran::lower::omp::ConstructQueue Fortran::lower::omp::buildConstructQueue(mlir::ModuleOp, Fortran::semantics::SemanticsContext &, Fortran::lower::pft::Evaluation &, const parser::CharBlock &, llvm::omp::Directive, const List<Fortran::lower::omp::Clause> &): Assertion `!decompose.output.empty() && "Construct decomposition failed"' failed.
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEVE2L4zgQ_TXKpehgl-0kPvjgTtrLwgwzyw4Mexpkq2JrR5GMPtKd_fWLbCed7h4YCEGFX71SvXoq7pzsNVHFikdWHFY8-MHY6ucDt9Y8u1VrxKX6PpCGzpxGqaTuwQ8ER6OUeY5RY6y3PH4XBM_SD9AornuG-wk4p5GFznI3kFuzpP42SDfjpQOpPWkvjeZKXUDqM1dSANcC3GCCEuCt7HuywMFdtOcvQNYaG_nb4EFq54mLGE51P9SxNFojQkcWnrmDnjRZ7klAe4H9wP0fX79F7OD96FhWM2wYNr0RrVF-bWzPsPmPYeOKkp_L4ukfltRsk8y_Y5nEEFOGuTmN4KiLnTgYueVKkfrVV5bUAAAvwLJD_MdHSN_gKPa-MLGkJi3ua8ZzUn-PQnPnyEbYA2neKhJwvEr_J_TGv5vUDQ5HLlWwFNu9Y_YvniX1TJHVwLAZuR9-ePNjtOZf6jzDRqnz6eE1XOo1SrYMm0_mmSzD5stI-vNXhs2B4viNI7vuxpFl9W4bmRfLxPJZraak6WhO43zYG-28DZ3_K1Cg3-PbIJV4m8Rwd1JyAX42Iij6Mk4uuSdzdOLay87N4d_XcG-0pxcPDDcfcu4uMB79fHg6cxX4pO2S0sXbRB-4K3g_cPuoTPfzColavmvkIG0c_JleKT5J51m2_71migdHLHua6csodH2beJwwpuI6j7UJfgx-TafRXxjuGJZz2gYY4k1JuCbIm21IMESG2yVY3xtoJapMlFnJV1Sl23yT5rtil6yGqutEmWbbts03HDFtjyJNMtFm2zIXebITK1lhgkVSJJik6QaTdYopdWWa5eUuK3dbYnlCJy7VOooWn-VKOheoSrMdYr5SvCXlpiWGuJgS4z6z1eTYNvSO5YmSzrtXCi-9mjbfvLGKAyseF-8Wh7frBIy-7aYZAuI6qyjZr18_4ipYVb3bLdIPoV135rS8p4_PaurNMWyW9s4V_h8AAP__stfQ4w">