[flang-commits] [flang] 7eec2f2 - [flang] Avoid infinite recursion in common block check

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Mon Feb 13 05:48:49 PST 2023


Author: Leandro Lupori
Date: 2023-02-13T10:48:32-03:00
New Revision: 7eec2f2f218cd23a055dc81295c930a0674f5797

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

LOG: [flang] Avoid infinite recursion in common block check

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

Reviewed By: klausler

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

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-names.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 76dfb521211ba..3772c6b07b400 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -5768,7 +5768,14 @@ void DeclarationVisitor::CheckCommonBlockDerivedType(
       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);
+            }
           }
         }
       }


        


More information about the flang-commits mailing list