diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp --- a/flang/lib/Semantics/resolve-names.cpp +++ b/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); + } } } }