Skip to content

Commit b8a929c

Browse files
committed
[flang] Fix regression with recent work on intrinsic/generic interactions
When resolving a procedure reference, do not allow a successful intrinsic procedure probe result to override an existing symbol. Differential Revision: https://reviews.llvm.org/D123905
1 parent ba01306 commit b8a929c

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

flang/lib/Evaluate/intrinsics.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2414,7 +2414,7 @@ std::optional<SpecificCall> IntrinsicProcTable::Implementation::Probe(
24142414
"Cannot use intrinsic function '%s' as a subroutine"_err_en_US,
24152415
call.name);
24162416
}
2417-
return std::nullopt; // TODO
2417+
return std::nullopt;
24182418
}
24192419

24202420
// Helper to avoid emitting errors before it is sure there is no match

flang/lib/Semantics/expression.cpp

+15-16
Original file line numberDiff line numberDiff line change
@@ -2186,24 +2186,23 @@ auto ExpressionAnalyzer::GetCalleeAndArguments(const parser::Name &name,
21862186
}
21872187
if (!resolution) {
21882188
// Not generic, or no resolution; may be intrinsic
2189-
if (!symbol->attrs().test(semantics::Attr::EXTERNAL)) {
2190-
if (std::optional<SpecificCall> specificCall{context_.intrinsics().Probe(
2191-
CallCharacteristics{ultimate.name().ToString(), isSubroutine},
2192-
arguments, GetFoldingContext())}) {
2193-
CheckBadExplicitType(*specificCall, *symbol);
2194-
return CalleeAndArguments{
2195-
ProcedureDesignator{std::move(specificCall->specificIntrinsic)},
2196-
std::move(specificCall->arguments)};
2197-
} else if (symbol->attrs().test(semantics::Attr::INTRINSIC)) {
2198-
return std::nullopt;
2189+
bool isIntrinsic{symbol->attrs().test(semantics::Attr::INTRINSIC)};
2190+
if (!isIntrinsic && !isGenericInterface) {
2191+
resolution = symbol;
2192+
} else if (std::optional<SpecificCall> specificCall{
2193+
context_.intrinsics().Probe(
2194+
CallCharacteristics{
2195+
ultimate.name().ToString(), isSubroutine},
2196+
arguments, GetFoldingContext())}) {
2197+
CheckBadExplicitType(*specificCall, *symbol);
2198+
return CalleeAndArguments{
2199+
ProcedureDesignator{std::move(specificCall->specificIntrinsic)},
2200+
std::move(specificCall->arguments)};
2201+
} else {
2202+
if (isGenericInterface) {
2203+
EmitGenericResolutionError(*symbol, dueToNullActual);
21992204
}
2200-
}
2201-
if (isGenericInterface) {
2202-
EmitGenericResolutionError(*symbol, dueToNullActual);
22032205
return std::nullopt;
2204-
} else {
2205-
// Neither a generic interface nor an intrinsic
2206-
resolution = symbol;
22072206
}
22082207
}
22092208
if (resolution->GetUltimate().has<semantics::DerivedTypeDetails>()) {

0 commit comments

Comments
 (0)