Fortran: Fix user-defined operator resolution in named BLOCKs (PR126127)
Correctly resolves user-defined operators within named `BLOCK` constructs in Fortran.
This commit resolves an issue where user-defined operators were not being correctly resolved within named BLOCK constructs in Fortran code. The fix in interface.cc ensures that the compiler correctly searches user-defined operator lists when a symbol refers to a function within these constructs. A new test case verifies the correction.
In Details
In gcc/fortran/interface.cc, the find_symtree0 and gfc_find_sym_in_symtree functions have been updated to improve symbol resolution for user-defined operators within named BLOCK constructs. Specifically, gfc_find_sym_in_symtree now includes a check against the user-defined operator list when the symbol being looked up pertains to a function, ensuring these operators are correctly found when they are used within the scope of a named BLOCK.
- user-defined operators
- In Fortran, procedures that can be invoked using operator syntax (e.g.,
a + b, where+is defined by a procedure) rather than function call syntax. - named BLOCK
- A Fortran construct that allows a block of code to be named and scoped, similar to a subroutine or module procedure, providing a way to group statements and declare local variables.
- symbol resolution
- The process by which a compiler determines the meaning and location of identifiers (symbols) used in the source code, such as variables, functions, and operators.