[flang-commits] [PATCH] D110952: [flang] Better error recovery for missing THEN in ELSE IF

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Oct 4 09:38:26 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG0061e681a329: [flang] Better error recovery for missing THEN in ELSE IF (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110952/new/

https://reviews.llvm.org/D110952

Files:
  flang/lib/Evaluate/check-expression.cpp
  flang/lib/Parser/executable-parsers.cpp
  flang/test/Parser/elseif-then.f90


Index: flang/test/Parser/elseif-then.f90
===================================================================
--- /dev/null
+++ flang/test/Parser/elseif-then.f90
@@ -0,0 +1,8 @@
+! RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s
+! CHECK-NOT: expected '=>'
+! CHECK: error: expected 'THEN'
+if (.false.) then
+else if (.false.)
+else
+end if
+end
Index: flang/lib/Parser/executable-parsers.cpp
===================================================================
--- flang/lib/Parser/executable-parsers.cpp
+++ flang/lib/Parser/executable-parsers.cpp
@@ -310,7 +310,7 @@
         many(construct<IfConstruct::ElseIfBlock>(
             unambiguousStatement(construct<ElseIfStmt>(
                 "ELSE IF" >> parenthesized(scalarLogicalExpr),
-                "THEN" >> maybe(name))),
+                recovery("THEN"_tok, ok) >> maybe(name))),
             block)),
         maybe(construct<IfConstruct::ElseBlock>(
             statement(construct<ElseStmt>("ELSE" >> maybe(name))), block)),
Index: flang/lib/Evaluate/check-expression.cpp
===================================================================
--- flang/lib/Evaluate/check-expression.cpp
+++ flang/lib/Evaluate/check-expression.cpp
@@ -93,7 +93,7 @@
 }
 
 bool IsConstantExprHelper::operator()(const ProcedureRef &call) const {
-  // LBOUND, UBOUND, and SIZE with DIM= arguments will have been reritten
+  // LBOUND, UBOUND, and SIZE with DIM= arguments will have been rewritten
   // into DescriptorInquiry operations.
   if (const auto *intrinsic{std::get_if<SpecificIntrinsic>(&call.proc().u)}) {
     if (intrinsic->name == "kind" ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110952.376926.patch
Type: text/x-patch
Size: 1610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211004/b1d9f883/attachment.bin>


More information about the flang-commits mailing list