[flang-commits] [PATCH] D126147: [flang] Fix crash in semantics after PDT instantiation

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue May 24 11:06:25 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG03095bd97b81: [flang] Fix crash in semantics after PDT instantiation (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126147/new/

https://reviews.llvm.org/D126147

Files:
  flang/lib/Semantics/type.cpp


Index: flang/lib/Semantics/type.cpp
===================================================================
--- flang/lib/Semantics/type.cpp
+++ flang/lib/Semantics/type.cpp
@@ -373,8 +373,11 @@
 }
 
 void InstantiateHelper::InstantiateComponents(const Scope &fromScope) {
-  for (const auto &pair : fromScope) {
-    InstantiateComponent(*pair.second);
+  // Instantiate symbols in declaration order; this ensures that
+  // parent components and type parameters of ancestor types exist
+  // by the time that they're needed.
+  for (SymbolRef ref : fromScope.GetSymbols()) {
+    InstantiateComponent(*ref);
   }
   ComputeOffsets(context(), scope_);
 }
@@ -396,7 +399,7 @@
 
   void Post(const parser::Name &name) {
     if (name.symbol && name.symbol->has<TypeParamDetails>()) {
-      name.symbol = scope_.FindSymbol(name.source);
+      name.symbol = scope_.FindComponent(name.source);
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126147.431731.patch
Type: text/x-patch
Size: 902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220524/cc58519f/attachment.bin>


More information about the flang-commits mailing list