GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
openmp

Fix Fortran pointer handling for OpenMP defaultmap

Corrects OpenMP defaultmap handling for Fortran pointers and adds support for OpenMP 6.1 'optional' modifier.

This commit rectifies misclassifications of Fortran pointer arrays and derived types within OpenMP’s defaultmap clause. Pointer arrays were incorrectly treated as aggregates, and derived types passed by pointer were mishandled. The fix implements these checks as language hooks, aligning behavior with allocatables and scalars. Additionally, it introduces a missing diagnostic for defaultmap and adds parser support for the optional modifier from OpenMP 6.1.

In Details

The OpenMP implementation for Fortran had issues correctly identifying pointer types for defaultmap purposes. Specifically, local pointer arrays were flagged as aggregates, and derived types passed by pointer were incorrectly handled. This patch introduces gfc_omp_pointer_p and LANG_HOOKS_OMP_POINTER_P lang hooks to properly distinguish these cases, mirroring the existing handling for scalars and allocatables. It also adds parsing for the OpenMP 6.1 optional modifier and improves diagnostic messages.

For Context
OpenMP
An API that supports multi-platform shared-memory parallel programming of C, C++, and Fortran on the largest U.S. high-performance systems.
defaultmap
An OpenMP clause that specifies the default data mapping (e.g., shared, private) for variables within a parallel construct when not explicitly declared otherwise.
Fortran array descriptor
A data structure used in Fortran to describe an array, containing information such as its base address, shape, and stride, allowing for flexible array manipulation.
Derived type
In Fortran, a user-defined data type that can aggregate other data types, similar to structures or classes in other languages.
Language hook
A mechanism in GCC that allows different language frontends to provide specific implementations for common operations or checks used by the compiler's middle-end or backends.
optional modifier
A modifier in OpenMP 6.1 that can be used with directives to indicate that a clause or argument is optional.
Filed Under: openmpfortranpointerdefaultmap