GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
fortran

fortran: Add accessors for the dtype field

Fortran array descriptors now use dedicated accessors for the dtype field, replacing direct access.

This commit introduces dedicated getter and setter functions (gfc_conv_descriptor_dtype_get and gfc_conv_descriptor_dtype_set) for the dtype field of Fortran array descriptors. Direct public access to this field is removed, enforcing encapsulation and ensuring consistent modification through the new accessor functions. This change also updates numerous call sites across the Fortran frontend.

In Details

Enhancing the Fortran attribute handling, this patch renames the internal gfc_conv_descriptor_dtype function to conv_descriptor_dtype and introduces gfc_conv_descriptor_dtype_get and gfc_conv_descriptor_dtype_set functions. These new accessors manage the dtype field of array descriptors, replacing the previous direct access method. This change affects various translation routines, including those for array creation, initialization, expression conversion, and assignment, promoting a more robust and maintainable descriptor interface.

For Context
dtype
Data type; refers to the type of elements stored in a Fortran array (e.g., integer, real, character).
accessor functions
Functions that provide controlled read (getters) or write (setters) access to the fields of a data structure, encapsulating direct memory manipulation.
array descriptor
A data structure used in Fortran to describe the properties of an array, such as its base address, dimensions, and data type. It allows for dynamic array sizing and passing arrays by reference.
Filed Under: fortrancompilerrefactor