[flang-commits] [PATCH] D124276: [flang] Fix regression from generic fix

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Apr 22 10:33:48 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.

A recent change that corrected the name resolution of a generic interface
when the same name was visible in scope incorrectly prevented a local
generic from shadowing an outer name that is not a generic, subprogram,
or derived type -- e.g., a simple variable -- leading to an inappropriate
error message.


https://reviews.llvm.org/D124276

Files:
  flang/lib/Semantics/resolve-names.cpp


Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -6962,16 +6962,18 @@
       info.Resolve(existing);
       return;
     }
-    if (ultimate.has<SubprogramDetails>() ||
-        ultimate.has<SubprogramNameDetails>()) {
-      genericDetails.set_specific(ultimate);
-    } else if (ultimate.has<DerivedTypeDetails>()) {
-      genericDetails.set_derivedType(ultimate);
-    } else {
-      SayAlreadyDeclared(symbolName, *existing);
-      return;
+    if (&existing->owner() == &currScope()) {
+      if (ultimate.has<SubprogramDetails>() ||
+          ultimate.has<SubprogramNameDetails>()) {
+        genericDetails.set_specific(ultimate);
+      } else if (ultimate.has<DerivedTypeDetails>()) {
+        genericDetails.set_derivedType(ultimate);
+      } else {
+        SayAlreadyDeclared(symbolName, *existing);
+        return;
+      }
+      EraseSymbol(*existing);
     }
-    EraseSymbol(*existing);
   }
   info.Resolve(&MakeSymbol(symbolName, Attrs{}, std::move(genericDetails)));
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124276.424524.patch
Type: text/x-patch
Size: 1147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220422/8e52b18d/attachment.bin>


More information about the flang-commits mailing list