[flang-commits] [flang] [flang][OpenMP] Reorganize ALLOCATE-related semantic checks (PR #165719)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Thu Oct 30 07:11:39 PDT 2025


kparzysz wrote:

The executable ALLOCATE is unique in the sense that the construct consists of _several_ OpenMP directives, plus a Fortran ALLOCATE statement.  All of the constituent directives have the same syntax, e.g.
```
!$omp allocate(x, y, z)
!$omp allocate(a, b, c)
allocate(x, y, z, a, b, c)
```
Internally, OpenMPExecutableAllocate has the list of objects and clauses that correspond to the first directive, while the other directives are stored as OpenMPDeclarativeAllocate's.  The latter has a typical structure, i.e. a single directive with arguments and clauses.  This means that even though the constituent directives have the same syntax, and are subject to the same restrictions, internally the first one is represented differently from the other ones.  This requires two pieces of code to verify the restrictions on the executable ALLOCATE.  In this patch, both use CheckAllocateDirective. These checks are done in the Enter function.

Additionally, the executable ALLOCATE imposes restrictions on the construct as a whole: those are checked in the Leave function.

The ALLOCATORS construct is the replacement of the executable ALLOCATE, starting in 5.2.  Instead of having several directives, it allows multiple ALLOCATE clauses to convey the information.  Similarly to the executable ALLOCATE, the checks for restrictions on individual ALLOCATE clauses are done in the Enter function, while the checks for the whole construct are done in the Leave function.  The actual restrictions are different enough from those on ALLOCATE directives that the checks could not be reused.

https://github.com/llvm/llvm-project/pull/165719


More information about the flang-commits mailing list