Index: flang/lib/Parser/executable-parsers.cpp =================================================================== --- flang/lib/Parser/executable-parsers.cpp +++ flang/lib/Parser/executable-parsers.cpp @@ -305,7 +305,8 @@ TYPE_CONTEXT_PARSER("IF construct"_en_US, construct( statement(construct(maybe(name / ":"), - "IF" >> parenthesized(scalarLogicalExpr) / "THEN")), + "IF" >> parenthesized(scalarLogicalExpr) / + recovery("THEN"_tok, lookAhead(endOfStmt)))), block, many(construct( unambiguousStatement(construct( Index: flang/test/Parser/missing-then.f90 =================================================================== --- /dev/null +++ flang/test/Parser/missing-then.f90 @@ -0,0 +1,8 @@ +! RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s +!CHECK: expected 'THEN' +!CHECK-NOT: expected 'PAUSE' +if (.TRUE.) +!CHECK: expected 'THEN' +else if (.FALSE.) +end if +end