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

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Wed Feb 15 12:05:26 PST 2023


Author: Peter Klausler
Date: 2023-02-15T12:05:12-08:00
New Revision: ee437afa912b2608dad783225ec8e98d98f5a084

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

LOG: [flang] Don't add a source range to a type instantiation's scope

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.

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

Added: 
    

Modified: 
    flang/lib/Semantics/type.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/type.cpp b/flang/lib/Semantics/type.cpp
index bc8667e43f107..afc2baaaeedef 100644
--- a/flang/lib/Semantics/type.cpp
+++ b/flang/lib/Semantics/type.cpp
@@ -368,7 +368,6 @@ void DerivedTypeSpec::Instantiate(Scope &containingScope) {
   }
   // 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(


        


More information about the flang-commits mailing list