diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -1152,6 +1152,11 @@ return false; } std::optional msg; + auto checkDefinedOperatorArgs = [&, opName, specific, proc]() { + bool arg0Defined = CheckDefinedOperatorArg(opName, specific, proc, 0); + bool arg1Defined = CheckDefinedOperatorArg(opName, specific, proc, 1); + return (arg0Defined & arg1Defined); + }; if (specific.attrs().test(Attr::NOPASS)) { // C774 msg = "%s procedure '%s' may not have NOPASS attribute"_err_en_US; } else if (!proc.functionResult.has_value()) { @@ -1161,8 +1166,7 @@ " result"_err_en_US; } else if (auto m{CheckNumberOfArgs(kind, proc.dummyArguments.size())}) { msg = std::move(m); - } else if (!CheckDefinedOperatorArg(opName, specific, proc, 0) | - !CheckDefinedOperatorArg(opName, specific, proc, 1)) { + } else if (!checkDefinedOperatorArgs()) { return false; // error was reported } else if (ConflictsWithIntrinsicOperator(kind, proc)) { msg = "%s function '%s' conflicts with intrinsic operator"_err_en_US;