diff --git a/flang/lib/Evaluate/check-expression.cpp b/flang/lib/Evaluate/check-expression.cpp --- a/flang/lib/Evaluate/check-expression.cpp +++ b/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(&call.proc().u)}) { if (intrinsic->name == "kind" || diff --git a/flang/lib/Parser/executable-parsers.cpp b/flang/lib/Parser/executable-parsers.cpp --- a/flang/lib/Parser/executable-parsers.cpp +++ b/flang/lib/Parser/executable-parsers.cpp @@ -310,7 +310,7 @@ many(construct( unambiguousStatement(construct( "ELSE IF" >> parenthesized(scalarLogicalExpr), - "THEN" >> maybe(name))), + recovery("THEN"_tok, ok) >> maybe(name))), block)), maybe(construct( statement(construct("ELSE" >> maybe(name))), block)), diff --git a/flang/test/Parser/elseif-then.f90 b/flang/test/Parser/elseif-then.f90 new file mode 100644 --- /dev/null +++ b/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