@@ -2907,7 +2907,7 @@ std::pair<const Symbol *, bool> ExpressionAnalyzer::ResolveGeneric(
2907
2907
continue ;
2908
2908
}
2909
2909
// Matching distance is smaller than the previously matched
2910
- // specific. Let it go thourgh so the current procedure is picked.
2910
+ // specific. Let it go through so the current procedure is picked.
2911
2911
} else {
2912
2912
// 16.9.144(6): a bare NULL() is not allowed as an actual
2913
2913
// argument to a generic procedure if the specific procedure
@@ -4824,31 +4824,41 @@ bool ArgumentAnalyzer::OkLogicalIntegerAssignment(
4824
4824
4825
4825
std::optional<ProcedureRef> ArgumentAnalyzer::GetDefinedAssignmentProc () {
4826
4826
const Symbol *proc{nullptr };
4827
+ bool isProcElemental{false };
4827
4828
std::optional<int > passedObjectIndex;
4828
4829
std::string oprNameString{" assignment(=)" };
4829
4830
parser::CharBlock oprName{oprNameString};
4830
4831
const auto &scope{context_.context ().FindScope (source_)};
4831
- // If multiple resolutions were possible, they will have been already
4832
- // diagnosed.
4833
4832
{
4834
4833
auto restorer{context_.GetContextualMessages ().DiscardMessages ()};
4835
4834
if (const Symbol *symbol{scope.FindSymbol (oprName)}) {
4836
4835
ExpressionAnalyzer::AdjustActuals noAdjustment;
4837
4836
proc =
4838
4837
context_.ResolveGeneric (*symbol, actuals_, noAdjustment, true ).first ;
4838
+ if (proc) {
4839
+ isProcElemental = IsElementalProcedure (*proc);
4840
+ }
4839
4841
}
4840
- for (std::size_t i{0 }; !proc && i < actuals_.size (); ++i) {
4842
+ for (std::size_t i{0 }; (!proc || isProcElemental) && i < actuals_.size ();
4843
+ ++i) {
4841
4844
const Symbol *generic{nullptr };
4842
4845
if (const Symbol *
4843
4846
binding{FindBoundOp (oprName, i, generic, /* isSubroutine=*/ true )}) {
4844
- if (CheckAccessibleSymbol (scope, DEREF (generic))) {
4845
- // ignore inaccessible type-bound ASSIGNMENT(=) generic
4846
- } else if (const Symbol *
4847
- resolution{GetBindingResolution (GetType (i), *binding)}) {
4848
- proc = resolution;
4849
- } else {
4850
- proc = binding;
4851
- passedObjectIndex = i;
4847
+ // ignore inaccessible type-bound ASSIGNMENT(=) generic
4848
+ if (!CheckAccessibleSymbol (scope, DEREF (generic))) {
4849
+ const Symbol *resolution{GetBindingResolution (GetType (i), *binding)};
4850
+ const Symbol &newProc{*(resolution ? resolution : binding)};
4851
+ bool isElemental{IsElementalProcedure (newProc)};
4852
+ if (!proc || !isElemental) {
4853
+ // Non-elemental resolution overrides elemental
4854
+ proc = &newProc;
4855
+ isProcElemental = isElemental;
4856
+ if (resolution) {
4857
+ passedObjectIndex.reset ();
4858
+ } else {
4859
+ passedObjectIndex = i;
4860
+ }
4861
+ }
4852
4862
}
4853
4863
}
4854
4864
}
0 commit comments