[flang-commits] [PATCH] D118747: [flang] Silence bogus error on use after IMPORT

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Feb 2 11:16:14 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGaee705661fe8: [flang] Silence bogus error on use after IMPORT (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118747/new/

https://reviews.llvm.org/D118747

Files:
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/resolve29.f90


Index: flang/test/Semantics/resolve29.f90
===================================================================
--- flang/test/Semantics/resolve29.f90
+++ flang/test/Semantics/resolve29.f90
@@ -1,5 +1,5 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
-module m
+module m1
   type t1
   end type
   type t3
@@ -42,3 +42,15 @@
     call s5()
   end
 end module
+module m2
+  integer, parameter :: ck = kind('a')
+end module
+program main
+  use m2
+  interface
+    subroutine s0(x)
+      import :: ck
+      character(kind=ck) :: x ! no error
+    end subroutine
+  end interface
+end program
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -6769,9 +6769,12 @@
 void ResolveNamesVisitor::CheckImport(
     const SourceName &location, const SourceName &name) {
   if (auto *symbol{FindInScope(name)}) {
-    Say(location, "'%s' from host is not accessible"_err_en_US, name)
-        .Attach(symbol->name(), "'%s' is hidden by this entity"_en_US,
-            symbol->name());
+    const Symbol &ultimate{symbol->GetUltimate()};
+    if (&ultimate.owner() == &currScope()) {
+      Say(location, "'%s' from host is not accessible"_err_en_US, name)
+          .Attach(symbol->name(), "'%s' is hidden by this entity"_en_US,
+              symbol->name());
+    }
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118747.405369.patch
Type: text/x-patch
Size: 1422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220202/a034d02a/attachment.bin>


More information about the flang-commits mailing list