forked from OSchip/llvm-project
[flang] Recover better from syntax errors on USE statements
Original-commit: flang-compiler/f18@29968698d9 Reviewed-on: https://github.com/flang-compiler/f18/pull/731
This commit is contained in:
parent
98a7408347
commit
f9ed573b1d
|
@ -208,6 +208,7 @@ public:
|
|||
state.set_anyTokenMatched();
|
||||
}
|
||||
} else if (state.anyTokenMatched()) {
|
||||
emitMessage = state.messages().empty();
|
||||
messages.Annex(std::move(state.messages()));
|
||||
backtrack.set_anyTokenMatched();
|
||||
if (state.anyDeferredMessages()) {
|
||||
|
|
|
@ -307,7 +307,7 @@ TYPE_PARSER(construct<ProgramUnit>(indirect(Parser<Module>{})) ||
|
|||
// [declaration-construct]...
|
||||
TYPE_CONTEXT_PARSER("specification part"_en_US,
|
||||
construct<SpecificationPart>(many(openmpDeclarativeConstruct),
|
||||
many(unambiguousStatement(indirect(Parser<UseStmt>{}))),
|
||||
many(statement(indirect(Parser<UseStmt>{}))),
|
||||
many(unambiguousStatement(indirect(Parser<ImportStmt>{}))),
|
||||
implicitPart, many(declarationConstruct)))
|
||||
|
||||
|
@ -318,7 +318,7 @@ TYPE_CONTEXT_PARSER("specification part"_en_US,
|
|||
// statement.
|
||||
constexpr auto limitedSpecificationPart{inContext("specification part"_en_US,
|
||||
construct<SpecificationPart>(many(openmpDeclarativeConstruct),
|
||||
many(unambiguousStatement(indirect(Parser<UseStmt>{}))),
|
||||
many(statement(indirect(Parser<UseStmt>{}))),
|
||||
many(unambiguousStatement(indirect(Parser<ImportStmt>{}))),
|
||||
implicitPart, many(limitedDeclarationConstruct)))};
|
||||
|
||||
|
@ -3110,6 +3110,9 @@ constexpr auto moduleNature{
|
|||
// R1409 use-stmt ->
|
||||
// USE [[, module-nature] ::] module-name [, rename-list] |
|
||||
// USE [[, module-nature] ::] module-name , ONLY : [only-list]
|
||||
// N.B. Lookahead to the end of the statement is necessary to resolve
|
||||
// ambiguity with assignments and statement function definitions that
|
||||
// begin with the letters "USE".
|
||||
TYPE_PARSER(construct<UseStmt>("USE" >> optionalBeforeColons(moduleNature),
|
||||
name, ", ONLY :" >> optionalList(Parser<Only>{})) ||
|
||||
construct<UseStmt>("USE" >> optionalBeforeColons(moduleNature), name,
|
||||
|
|
Loading…
Reference in New Issue