[flang] Fix mod file generation of derived type initializers... (#70511)
... when the derived type used in the structure constructor(s) is from another module and not use-associated into the current module. This came up in a test with a derived type component default initializer of "c_null_ptr", which is replaced with the expression "__builtin_c_ptr(address=0_8)"; the derived type name "__builtin_c_ptr" is not available in the current scope, and the module file would fail semantic analysis when USE'd. The best solution that I found was to extend module file generation to detect this case and handle it by inserting the right USE association to the ultimate derived type symbol, possibly with renaming to a compiler-created name in the case of a conflict. To implement this transformation, it was necessary to fix the utility evaluate::CollectSymbols() to include the derived type symbol from a structure constructor. This involved extending the expression traversal framework to visit the derived type spec of a structure constructor. Extending CollectSymbols() caused a lowering test to fail mysteriously, so I tracked down the code in PFTBuilder that didn't expect to see a DerivedTypeDetails symbol and dealt with it there.
Loading
Please sign in to comment