[flang-commits] [flang] bcad53e - [flang] Add more qualification when creating names for compiler-generated USEs

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Wed Jun 15 14:22:26 PDT 2022


Author: Peter Klausler
Date: 2022-06-15T14:18:28-07:00
New Revision: bcad53e13175ef4f98764c7fa3588a7915dffe62

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

LOG: [flang] Add more qualification when creating names for compiler-generated USEs

When generic resolution finds its specific procedure in a module,
and that specific procedure is not use-associated into the local scope
(perhaps because it was PRIVATE, perhaps because the generic was
use-associated with ONLY:), we create a new use-association with
a renaming.  The name constructed for this renaming needs to be
additionally qualified with the module name of the specific procedure
in order to avoid clashing with another specific of the same name
that may have previously been use-associated in the same way from
a distinct module.

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

Added: 
    

Modified: 
    flang/lib/Semantics/expression.cpp
    flang/test/Semantics/modfile39.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 1d7026cc5e3c2..366259caef945 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -2210,6 +2210,7 @@ const Symbol &ExpressionAnalyzer::AccessSpecific(
     // Create a renaming USE of the specific procedure.
     auto rename{context_.SaveTempName(
         used->symbol().owner().GetName().value().ToString() + "$" +
+        specific.owner().GetName().value().ToString() + "$" +
         specific.name().ToString())};
     return *const_cast<semantics::Scope &>(scope)
                 .try_emplace(rename, specific.attrs(),

diff  --git a/flang/test/Semantics/modfile39.f90 b/flang/test/Semantics/modfile39.f90
index 6041d6cc73c6c..fbbd6ae4ce299 100644
--- a/flang/test/Semantics/modfile39.f90
+++ b/flang/test/Semantics/modfile39.f90
@@ -36,11 +36,11 @@ subroutine s(a)
 !Expect: m2.mod
 !module m2
 !use m1,only:gen
-!use m1,only:m1$priv=>priv
-!private::m1$priv
+!use m1,only:m1$m1$priv=>priv
+!private::m1$m1$priv
 !contains
 !subroutine s(a)
-!real(4)::a(1_8:int(m1$priv(1_4),kind=8))
+!real(4)::a(1_8:int(m1$m1$priv(1_4),kind=8))
 !end
 !end
 


        


More information about the flang-commits mailing list