Fortran avoids an ICE when submodule functions return pointers.
Fortran compiler no longer crashes (ICE) when a submodule function declares an implicit pointer result, improving error handling.
This commit resolves an Internal Compiler Error (ICE) that occurred in the Fortran frontend when a submodule function implicitly declared a pointer as its result. Previously, such declarations would lead to an unclassifiable statement error and subsequent ICE or compiler confusion. The fix prevents the compiler from erroneously committing a new symbol for the implicit result when it’s already recognized as part of the module procedure.
In Details
This change in decl.cc addresses an ICE within the Fortran frontend, specifically within variable_decl. The issue arose when a module procedure declared in a function, used within a submodule, implicitly referred to its pointer result. The fix prevents the compiler from committing a new symbol in this scenario if it matches implicit result of a module procedure. Instead of trying to create a new symbol, the code now jumps straight to cleanup when MATCH_YES is emitted for the implicit result, avoiding the ICE.
For Context
When you compile a program, the compiler translates your source code into machine-readable instructions. Sometimes, if the compiler encounters unexpected or malformed code, it can crash itself; this is called an Internal Compiler Error (ICE). This commit fixes an ICE in the Fortran part of the GCC compiler. The crash happened when a specific type of Fortran code, involving a function within a 'submodule' that was meant to return a 'pointer' as its result, confused the compiler. The fix teaches the compiler to correctly recognize this specific pattern, preventing it from getting into a confused state and crashing. Instead, it now handles the situation gracefully, allowing the compilation to continue.