Fortran: Fix ICE in allocatable finalization expression
Fixes an internal compiler error (ICE) in Fortran when finalizing allocatable variables before assignment.
This commit fixes an ICE in the Fortran front end that occurred during the finalization of allocatable variables before assignment. The fix ensures that gfc_conv_expr is called with the se.descriptor_only flag, preventing an implicit call to set_factored_descriptor_value. A new test case is added to verify the fix.
In Details
In trans.cc, when handling the finalization of allocatable and pointer left-hand sides (LHS) before assignment, gfc_conv_expr must be used with the se.descriptor_only flag. This prevents the implicit invocation of set_factored_descriptor_value by gfc_conv_expr_descriptor, which was causing the ICE. This issue is specific to the Fortran front end and doesn't directly interact with other parts of the compiler.
For Context
In Fortran, allocatable variables can be automatically deallocated and finalized when they are no longer needed—for example, before being assigned a new value. This commit addresses a bug in the compiler's finalization process, where it would crash (an ICE, or internal compiler error) when dealing with allocatable variables on the left side of an assignment. The fix ensures the compiler correctly handles the descriptor of the allocatable variable during finalization, preventing the crash. This makes the compiler more robust when dealing with allocatable variables in Fortran code.