[flang-commits] [PATCH] D143211: [flang] Avoid infinite recursion in common block check

Leandro Lupori via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Feb 2 12:43:40 PST 2023


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

Don't call CheckCommonBlockDerivedType() recursively if the
derived type symbol is the same symbol that is already being
processed. This can happen when a component is a pointer of the
same type as its parent component, for instance.

Fixes #60230

I'm not sure if this is the correct/best way to fix this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143211

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
@@ -5735,7 +5735,14 @@
       if (details) {
         if (const auto *type{details->type()}) {
           if (const auto *derived{type->AsDerived()}) {
-            CheckCommonBlockDerivedType(name, derived->typeSymbol());
+            const Symbol &derivedTypeSymbol = derived->typeSymbol();
+            // Don't call this method recursively if the derived type symbol
+            // is the same symbol that is already being processed.
+            // This can happen when a component is a pointer of the same type
+            // as its parent component, for instance.
+            if (derivedTypeSymbol != typeSymbol) {
+              CheckCommonBlockDerivedType(name, derivedTypeSymbol);
+            }
           }
         }
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143211.494412.patch
Type: text/x-patch
Size: 939 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230202/9311f10a/attachment.bin>


More information about the flang-commits mailing list