[flang-commits] [PATCH] D84283: [flang] Check for misplaced labels
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Jul 21 17:27:47 PDT 2020
klausler created this revision.
klausler added reviewers: sscalpone, PeteSteinfeld, schweitz.
klausler added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
In fixed form source, complain when a label digit appears
outside the label field & when a non-digit appears in the label
field.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84283
Files:
flang/lib/Parser/prescan.cpp
flang/lib/Parser/prescan.h
flang/test/Parser/badlabel.f
Index: flang/test/Parser/badlabel.f
===================================================================
--- /dev/null
+++ flang/test/Parser/badlabel.f
@@ -0,0 +1,14 @@
+! RUN: %f18 -E %s 2>&1 | FileCheck %s
+! CHECK: Label digit is not in fixed-form label field
+ 1 continue
+! CHECK: Label digit is not in fixed-form label field
+ 1 2 continue
+! CHECK-NOT: Label is not in fixed-form label field
+ con
+ 3 tinue
+! CHECK: Character in fixed-form label field must be a digit
+end
+! CHECK: 1continue
+! CHECK: 12continue
+! CHECK: continue
+! CHECK: end
Index: flang/lib/Parser/prescan.h
===================================================================
--- flang/lib/Parser/prescan.h
+++ flang/lib/Parser/prescan.h
@@ -220,8 +220,6 @@
cooked_.allSources().CompilerInsertionProvenance(' ')};
const Provenance backslashProvenance_{
cooked_.allSources().CompilerInsertionProvenance('\\')};
- const ProvenanceRange sixSpaceProvenance_{
- cooked_.allSources().AddCompilerInsertion(" "s)};
// To avoid probing the set of active compiler directive sentinel strings
// on every comment line, they're checked first with a cheap Bloom filter.
Index: flang/lib/Parser/prescan.cpp
===================================================================
--- flang/lib/Parser/prescan.cpp
+++ flang/lib/Parser/prescan.cpp
@@ -246,6 +246,7 @@
}
void Prescanner::LabelField(TokenSequence &token, int outCol) {
+ bool badLabel{false};
for (; *at_ != '\n' && column_ <= 6; ++at_) {
if (*at_ == '\t') {
++at_;
@@ -255,6 +256,11 @@
if (*at_ != ' ' &&
!(*at_ == '0' && column_ == 6)) { // '0' in column 6 becomes space
EmitChar(token, *at_);
+ if (!IsDecimalDigit(*at_) && !badLabel) {
+ Say(GetProvenance(at_),
+ "Character in fixed-form label field must be a digit"_en_US);
+ badLabel = true;
+ }
++outCol;
}
++column_;
@@ -262,17 +268,11 @@
if (outCol > 1) {
token.CloseToken();
}
- if (outCol < 7) {
- if (outCol == 1) {
- token.Put(" ", 6, sixSpaceProvenance_.start());
- } else {
- for (; outCol < 7; ++outCol) {
- token.PutNextTokenChar(' ', spaceProvenance_);
- }
- token.CloseToken();
- }
- }
SkipToNextSignificantCharacter();
+ if (IsDecimalDigit(*at_)) {
+ Say(GetProvenance(at_),
+ "Label digit is not in fixed-form label field"_en_US);
+ }
}
void Prescanner::SkipToEndOfLine() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84283.279674.patch
Type: text/x-patch
Size: 2489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200722/f4bc7847/attachment.bin>
More information about the flang-commits
mailing list