From f5202dd68fa88d93bcc3eee9f176b71c5af6d487 Mon Sep 17 00:00:00 2001 From: peter klausler Date: Mon, 12 Feb 2018 11:56:42 -0800 Subject: [PATCH] [flang] Fix column tracking in fixed form. 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 | 6 +++--- flang/lib/parser/prescan.cc | 9 +++++---- flang/lib/parser/prescan.h | 1 + flang/lib/parser/provenance.cc | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/flang/lib/parser/preprocessor.h b/flang/lib/parser/preprocessor.h index 1d7211d..c799f0d 100644 --- a/flang/lib/parser/preprocessor.h +++ b/flang/lib/parser/preprocessor.h @@ -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) { diff --git a/flang/lib/parser/prescan.cc b/flang/lib/parser/prescan.cc index ecfabad..65df502 100644 --- a/flang/lib/parser/prescan.cc +++ b/flang/lib/parser/prescan.cc @@ -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(); diff --git a/flang/lib/parser/prescan.h b/flang/lib/parser/prescan.h index bf665aa..bb5e41d 100644 --- a/flang/lib/parser/prescan.h +++ b/flang/lib/parser/prescan.h @@ -52,6 +52,7 @@ public: private: void BeginSourceLine(const char *at) { at_ = at; + column_ = 1; tabInCurrentLine_ = false; preventHollerith_ = false; delimiterNesting_ = 0; diff --git a/flang/lib/parser/provenance.cc b/flang/lib/parser/provenance.cc index 24bff96..9437427 100644 --- a/flang/lib/parser/provenance.cc +++ b/flang/lib/parser/provenance.cc @@ -101,7 +101,8 @@ void AllSources::Identify( std::pair 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); -- 2.7.4