fortran: Fix regression in SPEC benchmarks
Corrects a Fortran compiler regression that caused a SPEC benchmark test to fail.
A recent fix for PR126170 in the Fortran compiler inadvertently introduced a regression that failed a SPEC benchmark test (PR126234). The issue stemmed from the use of gfc_find_symbol, which had a side effect of triggering an error during symbol ambiguity checks within ambiguous_symbol after calling gfc_find_sym_tree. The fix replaces the direct call to gfc_find_symbol with a manual walk of the symbol tree, resolving the regression.
In Details
This commit addresses a regression in the Fortran frontend's module symbol reading logic. The fix for PR126170 incorrectly used gfc_find_symbol, which recursively calls gfc_find_sym_tree and subsequently ambiguous_symbol, leading to an erroneous symbol error. The change replaces this with a direct traversal of the symbol tree in read_module, avoiding the unintended side effect and resolving the SPEC benchmark failure.
- PR126170
- A problem report (PR) filed against the GCC compiler, indicating a specific bug or issue that was previously addressed.
- SPEC benchmarks
- A suite of standardized tests used to measure the performance of computer systems. Failures in these benchmarks often indicate regressions in compiler optimization or correctness.
- gfc_find_symbol
- A function within the GCC Fortran frontend (gfortran) likely responsible for searching for a symbol within the compiler's symbol tables.
- gfc_find_sym_tree
- A function called by
gfc_find_symbolthat presumably traverses the symbol tree data structure. - ambiguous_symbol
- A routine within the Fortran compiler that handles cases where a symbol name could refer to multiple entities, typically issuing an error or requiring qualification.
- module symbol reading
- The process by which the Fortran compiler reads and parses information about symbols (variables, functions, types, etc.) declared in module files (.mod) to make them available for use in other program units.