[all-commits] [llvm/llvm-project] 1bea03: [flang] Fix mod file generation of derived type in...

Peter Klausler via All-commits all-commits at lists.llvm.org
Tue Oct 31 12:17:13 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1bea0347bfbba19e5cfecb0c66846e2bb41dc338
      https://github.com/llvm/llvm-project/commit/1bea0347bfbba19e5cfecb0c66846e2bb41dc338
  Author: Peter Klausler <35819229+klausler at users.noreply.github.com>
  Date:   2023-10-31 (Tue, 31 Oct 2023)

  Changed paths:
    M flang/include/flang/Evaluate/constant.h
    M flang/include/flang/Evaluate/expression.h
    M flang/include/flang/Evaluate/traverse.h
    M flang/include/flang/Evaluate/type.h
    M flang/include/flang/Parser/message.h
    M flang/lib/Evaluate/formatting.cpp
    M flang/lib/Lower/PFTBuilder.cpp
    M flang/lib/Semantics/mod-file.cpp
    M flang/lib/Semantics/mod-file.h
    M flang/test/Semantics/modfile03.f90
    A flang/test/Semantics/modfile59.f90

  Log Message:
  -----------
  [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.




More information about the All-commits mailing list