Index: flang/lib/Semantics/expression.cpp =================================================================== --- flang/lib/Semantics/expression.cpp +++ flang/lib/Semantics/expression.cpp @@ -2186,24 +2186,23 @@ } if (!resolution) { // Not generic, or no resolution; may be intrinsic - if (!symbol->attrs().test(semantics::Attr::EXTERNAL)) { - if (std::optional specificCall{context_.intrinsics().Probe( - CallCharacteristics{ultimate.name().ToString(), isSubroutine}, - arguments, GetFoldingContext())}) { - CheckBadExplicitType(*specificCall, *symbol); - return CalleeAndArguments{ - ProcedureDesignator{std::move(specificCall->specificIntrinsic)}, - std::move(specificCall->arguments)}; - } else if (symbol->attrs().test(semantics::Attr::INTRINSIC)) { - return std::nullopt; + bool isIntrinsic{symbol->attrs().test(semantics::Attr::INTRINSIC)}; + if (!isIntrinsic && !isGenericInterface) { + resolution = symbol; + } else if (std::optional specificCall{ + context_.intrinsics().Probe( + CallCharacteristics{ + ultimate.name().ToString(), isSubroutine}, + arguments, GetFoldingContext())}) { + CheckBadExplicitType(*specificCall, *symbol); + return CalleeAndArguments{ + ProcedureDesignator{std::move(specificCall->specificIntrinsic)}, + std::move(specificCall->arguments)}; + } else { + if (!isIntrinsic) { + EmitGenericResolutionError(*symbol, dueToNullActual); } - } - if (isGenericInterface) { - EmitGenericResolutionError(*symbol, dueToNullActual); return std::nullopt; - } else { - // Neither a generic interface nor an intrinsic - resolution = symbol; } } if (resolution->GetUltimate().has()) {