[flang-commits] [flang] [flang] only instantiate referenced use associated variables (PR #222318)
via flang-commits
flang-commits at lists.llvm.org
Wed Sep 9 05:57:16 PDT 2026
================
@@ -16,6 +16,7 @@ end module m_coarray_test
program test
use m_coarray_test
+ module_coarray = 1.0
----------------
jeanPerier wrote:
@JDPailleux, I added you as a review to validate this behavior and test change.
Basically, global_ctor are currently emitted for all the coarray of a modules inside a compilation unit that is doing `use m` even if the coarray are not used in the compilation unit.
With the current change, the global_ctor is only emitted for coarrays that are used in the procedure/program doing the `use m`.
I think this is OK as `use m` should behave like `use m, only: x, y, ...` that lists everything that is actually used, and also because I see no point to register coarrays in a compilation unit that is not using them given other compilation unit that use them are registering them.
https://github.com/llvm/llvm-project/pull/222318
More information about the flang-commits
mailing list