[PATCH] D108623: [flang] Fix non-deterministic line output function

Ivan Zhechev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 24 04:53:53 PDT 2021


ijan1 created this revision.
ijan1 added reviewers: Meinersbur, Leporacanthicus, kiranchandramohan, jdoerfert, sscalpone, tskeith, clementval.
Herald added a subscriber: mgrang.
ijan1 requested review of this revision.
Herald added a project: LLVM.

The evaluation order for bitwise `OR` is undefined
as opposed to a logical `OR`. The arguments are
stored in variables to force a specific evaluation order.

A test in D107575 <https://reviews.llvm.org/D107575> relies on this change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108623

Files:
  flang/lib/Semantics/check-declarations.cpp


Index: flang/lib/Semantics/check-declarations.cpp
===================================================================
--- flang/lib/Semantics/check-declarations.cpp
+++ flang/lib/Semantics/check-declarations.cpp
@@ -1152,6 +1152,11 @@
     return false;
   }
   std::optional<parser::MessageFixedText> 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108623.368320.patch
Type: text/x-patch
Size: 1256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210824/4bc05599/attachment.bin>


More information about the llvm-commits mailing list