From: Leandro Lupori Date: Thu, 2 Feb 2023 20:28:32 +0000 (+0000) Subject: [flang] Avoid infinite recursion in common block check X-Git-Tag: upstream/17.0.6~17727 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7eec2f2f218cd23a055dc81295c930a0674f5797;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index 76dfb52..3772c6b 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); + } } } }