GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran/openmp

Fortran/OpenMP: Simplify `gfc_free_omp_namelist` interface.

The `gfc_free_omp_namelist` function in the Fortran front end now uses an enum to specify what needs to be freed, simplifying its interface and improving code…

The gfc_free_omp_namelist function in the Fortran front end now accepts an enum gfc_omp_list_type to determine which components of a namelist need to be freed, instead of multiple boolean arguments. This change centralizes the logic for determining what to free within the function itself, simplifying its interface and making it easier to use correctly. The commit also improves code readability by replacing magic numbers with enum values in list traversals.

In Details

The gfc_free_omp_namelist function is used to free resources associated with OpenMP namelists in the Fortran front end. This commit replaces the multiple boolean arguments with a single enum argument (gfc_omp_list_type) to specify which components to free. This refactoring improves the function's API and reduces the potential for errors. The change affects multiple call sites within openmp.cc and st.cc.

For Context

OpenMP is an API for writing parallel programs. Fortran support for OpenMP requires the front end to parse and represent OpenMP directives, including namelists, which group variables for data sharing. This commit refactors the function responsible for freeing the memory associated with these OpenMP namelists, making the code cleaner and less error-prone by using an enumeration to represent the different types of data that need to be freed.

Filed Under: fortranopenmprefactoring