From 795df002091425aebcaa5d7abfa020430f1ff08d Mon Sep 17 00:00:00 2001 From: peter klausler Date: Tue, 1 May 2018 15:54:04 -0700 Subject: [PATCH] [flang] Don't process preprocessor directives amid continuation lines any more. Original-commit: flang-compiler/f18@4a3dbb5d3e24559f20a90f4ebc021c294817cd24 Reviewed-on: https://github.com/flang-compiler/f18/pull/81 Tree-same-pre-rewrite: false --- flang/lib/parser/prescan.cc | 23 +++++++---------------- flang/lib/parser/prescan.h | 2 +- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/flang/lib/parser/prescan.cc b/flang/lib/parser/prescan.cc index 74cb600..f11e5cc 100644 --- a/flang/lib/parser/prescan.cc +++ b/flang/lib/parser/prescan.cc @@ -37,7 +37,7 @@ Prescanner::Prescanner(const Prescanner &that) : messages_{that.messages_}, cooked_{that.cooked_}, preprocessor_{that.preprocessor_}, inFixedForm_{that.inFixedForm_}, fixedFormColumnLimit_{that.fixedFormColumnLimit_}, - enableOldDebugLines_{that.enableOldDebugLines_}, + encoding_{that.encoding_}, enableOldDebugLines_{that.enableOldDebugLines_}, enableBackslashEscapesInCharLiterals_{ that.enableBackslashEscapesInCharLiterals_}, warnOnNonstandardUsage_{that.warnOnNonstandardUsage_}, @@ -633,19 +633,10 @@ bool Prescanner::IsNextLinePreprocessorDirective() const { return IsPreprocessorDirectiveLine(lineStart_); } -void Prescanner::SkipCommentLinesAndPreprocessorDirectives() { - while (lineStart_ < limit_) { - LineClassification line{ClassifyLine(lineStart_)}; - switch (line.kind) { - case LineClassification::Kind::PreprocessorDirective: - if (inPreprocessorDirective_) { - return; - } - preprocessor_.Directive(TokenizePreprocessorDirective(), this); - break; - case LineClassification::Kind::Comment: NextLine(); break; - default: return; - } +void Prescanner::SkipCommentLines() { + while (lineStart_ < limit_ && + ClassifyLine(lineStart_).kind == LineClassification::Kind::Comment) { + NextLine(); } } @@ -711,7 +702,7 @@ bool Prescanner::FixedFormContinuation() { if (*at_ == '&' && inCharLiteral_) { return false; } - SkipCommentLinesAndPreprocessorDirectives(); + SkipCommentLines(); const char *cont{FixedFormContinuationLine()}; if (cont == nullptr) { return false; @@ -732,7 +723,7 @@ bool Prescanner::FreeFormContinuation() { if (*p != '\n' && (inCharLiteral_ || *p != '!')) { return false; } - SkipCommentLinesAndPreprocessorDirectives(); + SkipCommentLines(); p = lineStart_; if (p >= limit_) { return false; diff --git a/flang/lib/parser/prescan.h b/flang/lib/parser/prescan.h index 344a955..44d5a20 100644 --- a/flang/lib/parser/prescan.h +++ b/flang/lib/parser/prescan.h @@ -148,7 +148,7 @@ private: void QuotedCharacterLiteral(TokenSequence *); void Hollerith(TokenSequence *, int); bool PadOutCharacterLiteral(TokenSequence *); - void SkipCommentLinesAndPreprocessorDirectives(); + void SkipCommentLines(); bool IsFixedFormCommentLine(const char *) const; bool IsFreeFormComment(const char *) const; std::optional IsIncludeLine(const char *) const; -- 2.7.4