[flang-commits] [PATCH] D114297: [flang] Remove typo that affected complex namelist input

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Nov 22 14:59:29 PST 2021


klausler updated this revision to Diff 389048.
klausler added a comment.

Extend existing test to cover this case; extend comment, tune predicate.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114297/new/

https://reviews.llvm.org/D114297

Files:
  flang/runtime/edit-input.cpp
  flang/unittests/Runtime/NumericalFormatTest.cpp


Index: flang/unittests/Runtime/NumericalFormatTest.cpp
===================================================================
--- flang/unittests/Runtime/NumericalFormatTest.cpp
+++ flang/unittests/Runtime/NumericalFormatTest.cpp
@@ -144,11 +144,11 @@
 }
 
 TEST(IOApiTests, ListInputTest) {
-  static const char input[]{",1*,(5.,6..)"};
+  static const char input[]{",1*,(5.,6.),(7.0,8.0)"};
   auto cookie{IONAME(BeginInternalListInput)(input, sizeof input - 1)};
 
   // Create real values for IO tests
-  static constexpr int numRealValues{6};
+  static constexpr int numRealValues{8};
   float z[numRealValues];
   for (int j{0}; j < numRealValues; ++j) {
     z[j] = -(j + 1);
@@ -166,7 +166,7 @@
                        << static_cast<int>(status);
 
   // Ensure writing complex values from floats does not result in an error
-  static constexpr int bufferSize{33};
+  static constexpr int bufferSize{39};
   char output[bufferSize];
   output[bufferSize - 1] = '\0';
   cookie = IONAME(BeginInternalListOutput)(output, bufferSize - 1);
@@ -182,7 +182,8 @@
                        << static_cast<int>(status);
 
   // Verify output buffer against expected value
-  static const char expect[bufferSize]{" (-1.,-2.) (-3.,-4.) (5.,6.)    "};
+  static const char expect[bufferSize]{
+      " (-1.,-2.) (-3.,-4.) (5.,6.) (7.,8.)  "};
   ASSERT_EQ(std::strncmp(output, expect, bufferSize), 0)
       << "Failed complex list-directed output, expected '" << expect
       << "', but got '" << output << "'";
Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -303,15 +303,15 @@
   for (; p < limit && (*p == ' ' || *p == '\t'); ++p) {
   }
   if (edit.descriptor == DataEdit::ListDirectedImaginaryPart) {
-    // Need a trailing ')'
+    // Need to consume a trailing ')' and any white space after
     if (p >= limit || *p != ')') {
       return false;
     }
-    for (++ ++p; p < limit && (*p == ' ' || *p == '\t'); ++p) {
+    for (++p; p < limit && (*p == ' ' || *p == '\t'); ++p) {
     }
   }
-  if (p < limit) {
-    return false; // unconverted characters remain in field
+  if (edit.width && p < str + *edit.width) {
+    return false; // unconverted characters remain in fixed width field
   }
   // Success on the fast path!
   // TODO: raise converted.flags as exceptions?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114297.389048.patch
Type: text/x-patch
Size: 2407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211122/e83019a6/attachment.bin>


More information about the flang-commits mailing list