[flang-commits] [PATCH] D122763: [flang] Correct a typo when parsing format token white space

vdonaldson via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Mar 30 14:48:20 PDT 2022


vdonaldson created this revision.
vdonaldson added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
vdonaldson requested review of this revision.

A format such as "( D   C, X6. 2  )" is parsed the same as "(DC,X6.2)".


https://reviews.llvm.org/D122763

Files:
  flang/include/flang/Common/format.h
  flang/test/Semantics/io07.f90


Index: flang/test/Semantics/io07.f90
===================================================================
--- flang/test/Semantics/io07.f90
+++ flang/test/Semantics/io07.f90
@@ -5,8 +5,8 @@
      format(A)

 2001 format(3I8, 3Z8)
-2002 format(3I8, Z8)
-2003 format(  3  I  8  ,  3  Z  8  )
+2002 format(DC, F8.2, 3I8, Z8)
+2003 format(  D C , F 8 . 2 , 3  I  8  ,  3  Z  8  )
 2004 format(20PF10.2)
 2005 format(20P,F10.2)
 2006 format(20P7F10.2)
Index: flang/include/flang/Common/format.h
===================================================================
--- flang/include/flang/Common/format.h
+++ flang/include/flang/Common/format.h
@@ -172,24 +172,24 @@

 template <typename CHAR> CHAR FormatValidator<CHAR>::LookAheadChar() {
   for (laCursor_ = cursor_ + 1; laCursor_ < end_; ++laCursor_) {
-    if (!IsWhite(*cursor_)) {
+    if (!IsWhite(*laCursor_)) {
       return toupper(*laCursor_);
     }
   }
   laCursor_ = end_; // don't allow laCursor_ > end_
   return ' ';
 }

 // After a call to LookAheadChar, set token kind and advance cursor to laCursor.
 template <typename CHAR> void FormatValidator<CHAR>::Advance(TokenKind tk) {
   cursor_ = laCursor_;
   token_.set_kind(tk);
 }

 template <typename CHAR> void FormatValidator<CHAR>::NextToken() {
   // At entry, cursor_ points before the start of the next token.
   // At exit, cursor_ points to last CHAR of token_.

   previousTokenKind_ = token_.kind();
   CHAR c{NextChar()};
   token_.set_kind(TokenKind::None);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122763.419271.patch
Type: text/x-patch
Size: 1482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220330/05ed2e6b/attachment.bin>


More information about the flang-commits mailing list