[flang-commits] [PATCH] D123905: [flang] Fix intrinsic/generic interaction regression

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Sat Apr 16 16:12:56 PDT 2022


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

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


https://reviews.llvm.org/D123905

Files:
  flang/lib/Semantics/expression.cpp


Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -2186,24 +2186,23 @@
   }
   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 (!isIntrinsic) {
+        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>()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123905.423268.patch
Type: text/x-patch
Size: 1950 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220416/f05a2cf1/attachment.bin>


More information about the flang-commits mailing list