[flang-commits] [PATCH] D144129: [flang] Don't add a source range to a type instantiation's scope

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Feb 15 11:16:37 PST 2023


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

A type instantiation's scope doesn't require a source range, as we don't
need/want it to be the result of SemanticsContext::FindScope(), and
adding the original type's source range to the scope of one of its
instantiations has the side effect of expanding the source range of
all of its parents to include the original type definition, which
breaks FindScope() for any scope including a type instantiation.


https://reviews.llvm.org/D144129

Files:
  flang/lib/Semantics/type.cpp


Index: flang/lib/Semantics/type.cpp
===================================================================
--- flang/lib/Semantics/type.cpp
+++ flang/lib/Semantics/type.cpp
@@ -368,7 +368,6 @@
   }
   // Instantiate every non-parameter symbol from the original derived
   // type's scope into the new instance.
-  newScope.AddSourceRange(typeScope.sourceRange());
   auto restorer2{foldingContext.messages().SetContext(contextMessage)};
   if (PlumbPDTInstantiationDepth(&containingScope) > 100) {
     foldingContext.messages().Say(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144129.497757.patch
Type: text/x-patch
Size: 531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230215/d0611222/attachment-0001.bin>


More information about the flang-commits mailing list