[flang-commits] [flang] e962718 - [flang] Fix non-deterministic line output function
Ivan Zhechev via flang-commits
flang-commits at lists.llvm.org
Thu Sep 2 08:14:14 PDT 2021
Author: Ivan Zhechev
Date: 2021-09-02T15:13:45Z
New Revision: e962718dd5fc5e77d189729e3e1af34440450bdc
URL: https://github.com/llvm/llvm-project/commit/e962718dd5fc5e77d189729e3e1af34440450bdc
DIFF: https://github.com/llvm/llvm-project/commit/e962718dd5fc5e77d189729e3e1af34440450bdc.diff
LOG: [flang] Fix non-deterministic line output function
The evaluation order for the `|` operator is undefined
(in contrast to the short-circuiting `||` operator). The arguments are
stored in variables to force a specific evaluation order.
A test in D107575 relies on this change.
Reviewed By: kiranchandramohan, klausler
Differential Revision: https://reviews.llvm.org/D108623
Added:
Modified:
flang/lib/Semantics/check-declarations.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 4468784c06a17..368c8a108a5b9 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -1152,6 +1152,12 @@ bool CheckHelper::CheckDefinedOperator(SourceName opName, GenericKind kind,
return false;
}
std::optional<parser::MessageFixedText> msg;
+ auto checkDefinedOperatorArgs{
+ [&](SourceName opName, const Symbol &specific, const Procedure &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 +1167,7 @@ bool CheckHelper::CheckDefinedOperator(SourceName opName, GenericKind kind,
" 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(opName, specific, proc)) {
return false; // error was reported
} else if (ConflictsWithIntrinsicOperator(kind, proc)) {
msg = "%s function '%s' conflicts with intrinsic operator"_err_en_US;
More information about the flang-commits
mailing list