[flang-commits] [flang] bfcd536 - [flang] Give explicit convert= specifiers precedence over FORT_CONVERT

Jonathon Penix via flang-commits flang-commits at lists.llvm.org
Mon Sep 19 20:47:48 PDT 2022


Author: Jonathon Penix
Date: 2022-09-19T20:40:51-07:00
New Revision: bfcd536a8ef6b1d6e9dd211925be3b078d06fe77

URL: https://github.com/llvm/llvm-project/commit/bfcd536a8ef6b1d6e9dd211925be3b078d06fe77
DIFF: https://github.com/llvm/llvm-project/commit/bfcd536a8ef6b1d6e9dd211925be3b078d06fe77.diff

LOG: [flang] Give explicit convert= specifiers precedence over FORT_CONVERT

Currently, the FORT_CONVERT environment variable has the highest priority when
setting the endianness conversion for unformatted files. In discussing the
appropriate priority for the fconvert option, convert specifiers were decided
to take highest priority.

This patch also initializes the open statement convert state to unknown
to disambiguate cases where the convert specifier was not provided from
cases where convert=native was set. This makes it possible to defer to the
environment setting where appropriate.

Differential Revision: https://reviews.llvm.org/D133237

Added: 
    

Modified: 
    flang/runtime/io-stmt.h
    flang/runtime/unit.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/io-stmt.h b/flang/runtime/io-stmt.h
index 9e040e0e4ae13..a4aa908378215 100644
--- a/flang/runtime/io-stmt.h
+++ b/flang/runtime/io-stmt.h
@@ -555,7 +555,7 @@ class OpenStatementState : public ExternalIoStatementBase {
   std::optional<OpenStatus> status_;
   std::optional<Position> position_;
   std::optional<Action> action_;
-  Convert convert_{Convert::Native};
+  Convert convert_{Convert::Unknown};
   OwningPtr<char> path_;
   std::size_t pathLength_;
   std::optional<bool> isUnformatted_;

diff  --git a/flang/runtime/unit.cpp b/flang/runtime/unit.cpp
index be0791c192219..357d237c63e43 100644
--- a/flang/runtime/unit.cpp
+++ b/flang/runtime/unit.cpp
@@ -58,7 +58,7 @@ ExternalFileUnit *ExternalFileUnit::LookUpOrCreateAnonymous(int unit,
     IoErrorHandler handler{terminator};
     result->OpenAnonymousUnit(
         dir == Direction::Input ? OpenStatus::Unknown : OpenStatus::Replace,
-        Action::ReadWrite, Position::Rewind, Convert::Native, handler);
+        Action::ReadWrite, Position::Rewind, Convert::Unknown, handler);
     result->isUnformatted = isUnformatted;
   }
   return result;
@@ -92,7 +92,7 @@ ExternalFileUnit &ExternalFileUnit::NewUnit(
 void ExternalFileUnit::OpenUnit(std::optional<OpenStatus> status,
     std::optional<Action> action, Position position, OwningPtr<char> &&newPath,
     std::size_t newPathLength, Convert convert, IoErrorHandler &handler) {
-  if (executionEnvironment.conversion != Convert::Unknown) {
+  if (convert == Convert::Unknown) {
     convert = executionEnvironment.conversion;
   }
   swapEndianness_ = convert == Convert::Swap ||


        


More information about the flang-commits mailing list