https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122521
--- Comment #39 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Mikael Morin <[email protected]>: https://gcc.gnu.org/g:83b865a81345f3e4ffb78536b6b09bd5d60b1ee7 commit r17-6974-g83b865a81345f3e4ffb78536b6b09bd5d60b1ee7 Author: Mikael Morin <[email protected]> Date: Tue Dec 1 11:54:26 2026 +0100 fortran: array descriptor: Simplify scalar dtype initialization [PR122521] The functions gfc_set_descriptor_from_scalar_class and gfc_set_descriptor_from_scalar both create a new scalar descriptor type that is only used as argument to gfc_get_dtype, to get the dtype initialization value. gfc_get_dtype extracts two pieces of information from that descriptor type: the rank, and the element type. As the rank is known to be zero, and the element type was part of the input to create the descriptor type, we can avoid the roundtrip through the descriptor type creation, and use directly the zero rank and the element type. This change does that. It permits the removal of one argument from both scalar descriptor initialization functions. With the call to the descriptor type creation function removed, the pointer unwrapping of the element type the function was doing is removed as well. Add it back to the code of both scalar descriptor initialization functions. PR fortran/122521 gcc/fortran/ChangeLog: * trans-descriptor.h (gfc_set_descriptor_from_scalar_class, gfc_set_descriptor_from_scalar): Remove expression argument. * trans-descriptor.cc (gfc_set_descriptor_from_scalar_class, gfc_set_descriptor_from_scalar): Ditto. Explicitly unwrap element type if it's pointer-typed. Use gfc_get_dtype_rank_type instead of gfc_get_dtype. Remove scalar descriptor type creation. * trans-expr.cc (gfc_conv_derived_to_class, gfc_conv_class_to_class): Update callers.
