GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

fortran: Ignore attributes of class containers's _data component

Fixes Fortran compiler to correctly handle attributes for class containers' _data component.

The Fortran compiler now correctly handles attributes for class containers by ignoring the implicit _data component’s attributes. Previously, the compiler might miss or incorrectly report attributes if the last component reference was to _data, leading to incorrect error messages or missed checks for polymorphic function results and pointer assignments.

In Details

This commit addresses an issue in the Fortran frontend's attribute tracking for class containers. When referencing a component within a class container, specifically the implicit _data field, gfc_variable_attr incorrectly used attributes from this field. This change ensures that attributes are correctly propagated from the original entity rather than being masked by the _data component's limited attribute set. It also adjusts handling for polymorphic function results and pointer assignment checks to account for this.

For Context
class container
In Fortran, a derived type that contains components, where one of those components might be an instance of another derived type or a similar structure.
_data component
An implicit component within a Fortran class container that holds specific attributes related to the container's data, such as allocatable or pointer status.
polymorphic
In Fortran, a procedure or variable that can have different types at runtime, often managed through dynamic dispatch.
Filed Under: fortrancompilerattributes