[flang] Handle "type(foo) function f" when foo is defined in f
Fortran allows forward references to derived types, including function results that are typed in a prefix of a FUNCTION statement. If a type is defined in the body of the function, a reference to that type from a prefix on the FUNCTION statement must resolve to the local symbol, even and especially when that type shadows one from the host scope. The solution is to defer the processing of that type until the end of the function's specification part. But the language doesn't allow for forward references to other names in the prefix, so defer the processing of the type only when it is not an intrinsic type. The data structures in name resolution that track this information for functions needed to become a stack in order to make this work, since functions can contain interfaces that are functions. Differential Revision: https://reviews.llvm.org/D119448
Loading
Please register or sign in to comment