[PATCH] D84280: [flang] Fix source line continuation in potential macro calls (bugzilla 46768)
Peter Klausler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 21 18:22:36 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG320389e849f8: [flang] Fix source line continuation in potential macro calls (bugzilla 46768) (authored by klausler).
Changed prior to commit:
https://reviews.llvm.org/D84280?vs=279683&id=279689#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84280/new/
https://reviews.llvm.org/D84280
Files:
flang/lib/Parser/prescan.cpp
flang/lib/Parser/prescan.h
flang/test/Parser/continuation-in-if.f
Index: flang/test/Parser/continuation-in-if.f
===================================================================
--- /dev/null
+++ flang/test/Parser/continuation-in-if.f
@@ -0,0 +1,9 @@
+! RUN: %f18 -funparse %s 2>&1 | FileCheck %s
+! CHECK: CALL foo("N","N")
+#ifdef transpose
+ call foo('T',
+#else
+ call foo('N',
+#endif
+ $ 'N')
+ end
Index: flang/lib/Parser/prescan.h
===================================================================
--- flang/lib/Parser/prescan.h
+++ flang/lib/Parser/prescan.h
@@ -166,6 +166,7 @@
const char *IsPreprocessorDirectiveLine(const char *) const;
const char *FixedFormContinuationLine(bool mightNeedSpace);
const char *FreeFormContinuationLine(bool ampersand);
+ bool IsImplicitContinuation() const;
bool FixedFormContinuation(bool mightNeedSpace);
bool FreeFormContinuation();
bool Continuation(bool mightNeedFixedFormSpace);
Index: flang/lib/Parser/prescan.cpp
===================================================================
--- flang/lib/Parser/prescan.cpp
+++ flang/lib/Parser/prescan.cpp
@@ -887,10 +887,8 @@
return nextLine_ + 6;
}
}
- if (delimiterNesting_ > 0) {
- if (!IsFixedFormCommentChar(col1)) {
- return nextLine_;
- }
+ if (IsImplicitContinuation()) {
+ return nextLine_;
}
}
return nullptr; // not a continuation line
@@ -927,7 +925,7 @@
return p + 1;
} else if (*p == '!' || *p == '\n' || *p == '#') {
return nullptr;
- } else if (ampersand || delimiterNesting_ > 0) {
+ } else if (ampersand || IsImplicitContinuation()) {
if (p > nextLine_) {
--p;
} else {
@@ -981,6 +979,14 @@
return false;
}
+// Implicit line continuation allows a preprocessor macro call with
+// arguments to span multiple lines.
+bool Prescanner::IsImplicitContinuation() const {
+ return !inPreprocessorDirective_ && !inCharLiteral_ &&
+ delimiterNesting_ > 0 && nextLine_ < limit_ &&
+ ClassifyLine(nextLine_).kind == LineClassification::Kind::Source;
+}
+
bool Prescanner::Continuation(bool mightNeedFixedFormSpace) {
if (*at_ == '\n' || *at_ == '&') {
if (inFixedForm_) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84280.279689.patch
Type: text/x-patch
Size: 2186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200722/0c31138c/attachment.bin>
More information about the llvm-commits
mailing list