[flang-commits] [flang] b8a929c - [flang] Fix regression with recent work on intrinsic/generic interactions

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Apr 18 11:10:49 PDT 2022


Author: Peter Klausler
Date: 2022-04-18T11:10:41-07:00
New Revision: b8a929cb2f0ba3199823552269fe151682154703

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

LOG: [flang] Fix regression with recent work on intrinsic/generic interactions

When resolving a procedure reference, do not allow a successful
intrinsic procedure probe result to override an existing
symbol.

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

Added: 
    

Modified: 
    flang/lib/Evaluate/intrinsics.cpp
    flang/lib/Semantics/expression.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index d751c7410b23b..63a7f4e3fd213 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -2414,7 +2414,7 @@ std::optional<SpecificCall> IntrinsicProcTable::Implementation::Probe(
           "Cannot use intrinsic function '%s' as a subroutine"_err_en_US,
           call.name);
     }
-    return std::nullopt; // TODO
+    return std::nullopt;
   }
 
   // Helper to avoid emitting errors before it is sure there is no match

diff  --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 41c2492326d8c..146e4d1249f94 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -2186,24 +2186,23 @@ auto ExpressionAnalyzer::GetCalleeAndArguments(const parser::Name &name,
   }
   if (!resolution) {
     // Not generic, or no resolution; may be intrinsic
-    if (!symbol->attrs().test(semantics::Attr::EXTERNAL)) {
-      if (std::optional<SpecificCall> specificCall{context_.intrinsics().Probe(
-              CallCharacteristics{ultimate.name().ToString(), isSubroutine},
-              arguments, GetFoldingContext())}) {
-        CheckBadExplicitType(*specificCall, *symbol);
-        return CalleeAndArguments{
-            ProcedureDesignator{std::move(specificCall->specificIntrinsic)},
-            std::move(specificCall->arguments)};
-      } else if (symbol->attrs().test(semantics::Attr::INTRINSIC)) {
-        return std::nullopt;
+    bool isIntrinsic{symbol->attrs().test(semantics::Attr::INTRINSIC)};
+    if (!isIntrinsic && !isGenericInterface) {
+      resolution = symbol;
+    } else if (std::optional<SpecificCall> specificCall{
+                   context_.intrinsics().Probe(
+                       CallCharacteristics{
+                           ultimate.name().ToString(), isSubroutine},
+                       arguments, GetFoldingContext())}) {
+      CheckBadExplicitType(*specificCall, *symbol);
+      return CalleeAndArguments{
+          ProcedureDesignator{std::move(specificCall->specificIntrinsic)},
+          std::move(specificCall->arguments)};
+    } else {
+      if (isGenericInterface) {
+        EmitGenericResolutionError(*symbol, dueToNullActual);
       }
-    }
-    if (isGenericInterface) {
-      EmitGenericResolutionError(*symbol, dueToNullActual);
       return std::nullopt;
-    } else {
-      // Neither a generic interface nor an intrinsic
-      resolution = symbol;
     }
   }
   if (resolution->GetUltimate().has<semantics::DerivedTypeDetails>()) {


        


More information about the flang-commits mailing list