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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] BLOCK construct throws assertion error with OpenMP functions.
        </td>
    </tr>

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

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

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

<pre>
    According to the standard: "The BLOCK construct defines an **executable block** that can contain declarations."
Hence it should also support OpenMP functions inside it.

```
program block_r2
    implicit none
 BLOCK
        use omp_lib
        !$omp parallel
            print *, omp_get_thread_num()
        !$omp end parallel
    END BLOCK
end program block_r2

```
The above programs runs fine in gfortran,ifx but fails in llvm-flang with assertion error. 
Compiler explorer link: https://godbolt.org/z/59GGTco35

 

> flang-new: ~/llvm-project/flang/lib/Lower/Mangler.cpp:183: std::string Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol&, bool, bool): Assertion `(symbol.owner().kind() != Fortran::semantics::Scope::Kind::BlockConstruct || symbol.has<Fortran::semantics::SubprogramDetails>()) && "block object mangling must specify a scopeBlockIdMap"' failed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VFFzmzgQ_jXyy04ZEMbGDzwQO_Ru2rQ3c33PCGkBXYSkkUSd3MP99hsJ2iZpWsZjFknf6tvdb5d5L0eN2JDqhlSXHVvCZFwzMSf9xKf9rjfiqWk5N05IPUIwECYEH5gWzAlStkAo_TIh3Hz8fP4A3Ggf3MIDCBykRg9MA6EtoS0-Il8C6xVCrwx_WFchTCwAZzpCA5MaBHLFHAvSaJ8RSkl-IXn7B2qOIAP4ySxKAFPegF-sNS7AZ4v67i8YFs0TDKT2UsTj2Yre_g_59kuf1pnRsXllc--2iwAA5GyV5DKANhq35RTfjyPxWTyCme29kv3LDUILQvdmtmCZY0qherkfH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