[flang-commits] [PATCH] D142773: [flang] Fix ENUMERATOR declarations in nested scopes

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Jan 27 10:01:20 PST 2023


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

ENUMERATOR declarations are checking for conflicts between new
enumerator names and names in both the local scope and scopes
that contain it.  ENUMERATOR declarations belong to the local
scope and so only a conflict with a name therein is an error.
(In short, use FindInScope rather than FindSymbol.)


https://reviews.llvm.org/D142773

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
@@ -4180,7 +4180,7 @@
 
 bool DeclarationVisitor::Pre(const parser::Enumerator &enumerator) {
   const parser::Name &name{std::get<parser::NamedConstant>(enumerator.t).v};
-  Symbol *symbol{FindSymbol(name)};
+  Symbol *symbol{FindInScope(name)};
   if (symbol && !symbol->has<UnknownDetails>()) {
     // Contrary to named constants appearing in a PARAMETER statement,
     // enumerator names should not have their type, dimension or any other


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142773.492835.patch
Type: text/x-patch
Size: 643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230127/8b3ee78e/attachment-0001.bin>


More information about the flang-commits mailing list