[flang-commits] [flang] 6f30010 - [flang] Fix bug with IMPORT of USE of USE

Tim Keith via flang-commits flang-commits at lists.llvm.org
Mon May 11 13:30:13 PDT 2020


Author: Tim Keith
Date: 2020-05-11T13:28:07-07:00
New Revision: 6f300105d21e1f3bf7f0f92c2564c29f0cab8fb9

URL: https://github.com/llvm/llvm-project/commit/6f300105d21e1f3bf7f0f92c2564c29f0cab8fb9
DIFF: https://github.com/llvm/llvm-project/commit/6f300105d21e1f3bf7f0f92c2564c29f0cab8fb9.diff

LOG: [flang] Fix bug with IMPORT of USE of USE

When a module contained an import of a use-association of a
use-association, we weren't recognizing that the symbols was needed.
The fix is the follow all of the use-associations using `GetUltimate()`.

Differential Revision: https://reviews.llvm.org/D79737

Added: 
    flang/test/Semantics/modfile36.f90

Modified: 
    flang/lib/Semantics/mod-file.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index d5b754816640..ca1704e8012c 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -833,7 +833,7 @@ void SubprogramSymbolCollector::Collect() {
   for (const auto &pair : scope_) {
     const Symbol &symbol{*pair.second};
     if (const auto *useDetails{symbol.detailsIf<UseDetails>()}) {
-      if (useSet_.count(useDetails->symbol()) > 0) {
+      if (useSet_.count(useDetails->symbol().GetUltimate()) > 0) {
         need_.push_back(symbol);
       }
     }

diff  --git a/flang/test/Semantics/modfile36.f90 b/flang/test/Semantics/modfile36.f90
new file mode 100644
index 000000000000..b111d9eb7a6e
--- /dev/null
+++ b/flang/test/Semantics/modfile36.f90
@@ -0,0 +1,41 @@
+! RUN: %S/test_modfile.sh %s %t %f18
+
+! Check modfile that contains import of use-assocation of another use-association.
+
+module m1
+  interface
+     subroutine s(x)
+       use, intrinsic :: iso_c_binding, only: c_ptr
+       type(c_ptr) :: x
+     end subroutine
+  end interface
+end module
+!Expect: m1.mod
+!module m1
+! interface
+!  subroutine s(x)
+!   use iso_c_binding, only: c_ptr
+!   type(c_ptr) :: x
+!  end
+! end interface
+!end
+
+module m2
+  use, intrinsic :: iso_c_binding, only: c_ptr
+  interface
+     subroutine s(x)
+       import :: c_ptr
+       type(c_ptr) :: x
+     end subroutine
+  end interface
+end module
+!Expect: m2.mod
+!module m2
+! use iso_c_binding,only:c_ptr
+! interface
+!  subroutine s(x)
+!   import::c_ptr
+!   type(c_ptr)::x
+!  end
+! end interface
+!end


        


More information about the flang-commits mailing list