[flang] Resolve ambiguous I/O unit parse in favor of CharVariable.

Original-commit: flang-compiler/f18@ecabe82825
Reviewed-on: https://github.com/flang-compiler/f18/pull/416
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-04-15 17:09:48 -07:00
parent f7895f3ef0
commit 1b8a78ac13
2 changed files with 5 additions and 3 deletions

View File

@ -2422,8 +2422,10 @@ TYPE_CONTEXT_PARSER("UNLOCK statement"_en_US,
// R1201 io-unit -> file-unit-number | * | internal-file-variable
// R1203 internal-file-variable -> char-variable
TYPE_PARSER(construct<IoUnit>(fileUnitNumber) || construct<IoUnit>(star) ||
construct<IoUnit>(charVariable / !"="_tok))
// "char-variable" is attempted first since it's not type constrained but
// syntactically ambiguous with "file-unit-number", which is constrained.
TYPE_PARSER(construct<IoUnit>(charVariable / !"="_tok) ||
construct<IoUnit>(fileUnitNumber) || construct<IoUnit>(star))
// R1202 file-unit-number -> scalar-int-expr
TYPE_PARSER(construct<FileUnitNumber>(scalarIntExpr / !"="_tok))

View File

@ -2497,7 +2497,7 @@ WRAPPER_CLASS(FileUnitNumber, ScalarIntExpr);
// R1203 internal-file-variable -> char-variable
struct IoUnit {
UNION_CLASS_BOILERPLATE(IoUnit);
std::variant<FileUnitNumber, Star, CharVariable> u;
std::variant<CharVariable, FileUnitNumber, Star> u;
};
// R1206 file-name-expr -> scalar-default-char-expr