[flang] Fix column tracking in fixed form.
authorpeter klausler <pklausler@nvidia.com>
Mon, 12 Feb 2018 19:56:42 +0000 (11:56 -0800)
committerGitHub <noreply@github.com>
Thu, 15 Feb 2018 23:58:44 +0000 (15:58 -0800)
Original-commit: flang-compiler/f18@8c9a1013fa0861496e22cafde5d3c5326fae9a3a
Reviewed-on: https://github.com/flang-compiler/f18/pull/9
Tree-same-pre-rewrite: false

flang/lib/parser/preprocessor.h
flang/lib/parser/prescan.cc
flang/lib/parser/prescan.h
flang/lib/parser/provenance.cc

index 1d7211d..c799f0d 100644 (file)
@@ -88,9 +88,9 @@ public:
     Put(that, at, count);
   }
   TokenSequence(TokenSequence &&that)
-    : start_{std::move(that.start_)},
-      nextStart_{that.nextStart_}, char_{std::move(that.char_)},
-      provenances_{std::move(that.provenances_)} {}
+    : start_{std::move(that.start_)}, nextStart_{that.nextStart_},
+      char_{std::move(that.char_)}, provenances_{std::move(that.provenances_)} {
+  }
   TokenSequence(const std::string &s) { Put(s, 0); }  // TODO predefined prov.
 
   TokenSequence &operator=(const TokenSequence &that) {
index ecfabad..65df502 100644 (file)
@@ -468,22 +468,23 @@ bool Prescanner::FreeFormContinuation() {
   if (p >= limit_) {
     return false;
   }
-  column_ = 1;
+  int column{1};
   for (; *p == ' ' || *p == '\t'; ++p) {
-    ++column_;
+    ++column;
   }
   if (*p == '&') {
     ++p;
-    ++column_;
+    ++column;
   } else if (ampersand || delimiterNesting_ > 0) {
     if (p > lineStart_) {
       --p;
-      --column_;
+      --column;
     }
   } else {
     return false;  // not a continuation
   }
   at_ = p;
+  column_ = column;
   tabInCurrentLine_ = false;
   ++newlineDebt_;
   NextLine();
index bf665aa..bb5e41d 100644 (file)
@@ -52,6 +52,7 @@ public:
 private:
   void BeginSourceLine(const char *at) {
     at_ = at;
+    column_ = 1;
     tabInCurrentLine_ = false;
     preventHollerith_ = false;
     delimiterNesting_ = 0;
index 24bff96..9437427 100644 (file)
@@ -101,7 +101,8 @@ void AllSources::Identify(
                  std::pair<int, int> pos{
                      inc.source.FindOffsetLineAndColumn(at - origin.start)};
                  o << prefix << "at line " << pos.first << ", column "
-                   << pos.second << " in the file " << inc.source.path() << '\n';
+                   << pos.second << " in the file " << inc.source.path()
+                   << '\n';
                  if (origin.replaces.bytes > 0) {
                    o << prefix << " that was included\n";
                    Identify(o, origin.replaces.start, indented);