Fortran Fixes Complex Associate-Name with Inferred Kind
GCC now correctly handles complex associate-names with inferred kinds in Fortran, resolving a type mismatch error.
GCC’s Fortran compiler now correctly handles complex associate-names with inferred kinds. Previously, the kind type parameter was not correctly updated for INQUIRY_RE and INQUIRY_IM references within associate constructs, leading to type mismatches. This fix ensures the kind is properly updated, resolving errors when using complex associate-names with inferred types.
In Details
This commit addresses PR125172 in the Fortran frontend. The fix updates the kind for INQUIRY_RE and INQUIRY_IM references within inferred complex associate-names during gfc_fixup_inferred_type_refs in resolve.cc. It also refreshes the e->ts from sym->ts for inferred-type associate-names without subobject references in resolve_variable, and refreshes sym->ts from the resolved target when only the kind differs in resolve_assoc_var.
For Context
In Fortran, associate constructs allow you to assign a name to an expression or variable for use within a block of code. Type inference lets the compiler automatically deduce the data type of a variable. This commit fixes a bug where the compiler incorrectly handled complex numbers with inferred kinds in associate constructs, leading to errors when accessing the real and imaginary parts of the number. The compiler now correctly updates type information and resolves the type mismatches.