[PATCH] D84283: [flang] Check for misplaced labels
Peter Klausler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 21 18:01:10 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG26330a0c7c6e: [flang] Check for misplaced labels (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84283/new/
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.279684.patch
Type: text/x-patch
Size: 2489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200722/7b52ba86/attachment.bin>
More information about the llvm-commits
mailing list