[flang-commits] [flang] 7c84f6a - [flang] Emit portability warning for extension

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Feb 13 10:21:48 PST 2023


Author: Peter Klausler
Date: 2023-02-13T10:21:39-08:00
New Revision: 7c84f6a43ae384c9d90db3d93f03bffb363f0dcf

URL: https://github.com/llvm/llvm-project/commit/7c84f6a43ae384c9d90db3d93f03bffb363f0dcf
DIFF: https://github.com/llvm/llvm-project/commit/7c84f6a43ae384c9d90db3d93f03bffb363f0dcf.diff

LOG: [flang] Emit portability warning for extension

f18 accepts statement labels in fixed form source even if they follow
a semicolon -- i.e., they're not in the fixed form's label field.
Emit a warning for such usage.

Differential Revision: https://reviews.llvm.org/D143817

Added: 
    flang/test/Parser/bad-label.f

Modified: 
    flang/docs/Extensions.md
    flang/lib/Parser/prescan.cpp

Removed: 
    


################################################################################
diff  --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index 80e2a0c6520d..c9793f89836e 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -261,6 +261,7 @@ end
   to apply only to a scalar data-ref, but most compilers don't
   enforce it and the constraint is not necessary for a correct
   implementation.
+* A label may follow a semicolon in fixed form source.
 
 ### Extensions supported when enabled by options
 

diff  --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 9da30d2e6a09..be5e6037cac3 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -629,6 +629,12 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
       EmitCharAndAdvance(tokens, nch);
     } else if (ch == '/') {
       slashInCurrentStatement_ = true;
+    } else if (ch == ';' && InFixedFormSource()) {
+      SkipSpaces();
+      if (IsDecimalDigit(*at_)) {
+        Say(GetProvenanceRange(at_, at_ + 1),
+            "Label should be in the label field"_port_en_US);
+      }
     }
   }
   tokens.CloseToken();

diff  --git a/flang/test/Parser/bad-label.f b/flang/test/Parser/bad-label.f
new file mode 100644
index 000000000000..899ddff8c9d2
--- /dev/null
+++ b/flang/test/Parser/bad-label.f
@@ -0,0 +1,4 @@
+! RUN: %flang_fc1 -fsyntax-only -pedantic %s 2>&1 | FileCheck %s
+!CHECK: portability: Label should be in the label field
+      goto 1;  1 continue
+      end


        


More information about the flang-commits mailing list