[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
Fri Feb 3 09:31:07 PST 2023


luporl updated this revision to Diff 494670.
luporl edited the summary of this revision.
luporl added a comment.

Address reviewer's comments.


Repository:
  rG LLVM Github Monorepo

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

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 member function 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.494670.patch
Type: text/x-patch
Size: 947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230203/bae94328/attachment.bin>


More information about the flang-commits mailing list