diff --git a/flang/lib/Parser/Fortran-parsers.cpp b/flang/lib/Parser/Fortran-parsers.cpp --- a/flang/lib/Parser/Fortran-parsers.cpp +++ b/flang/lib/Parser/Fortran-parsers.cpp @@ -1084,7 +1084,8 @@ // R924 image-selector -> // lbracket cosubscript-list [, image-selector-spec-list] rbracket TYPE_CONTEXT_PARSER("image selector"_en_US, - construct("[" >> nonemptyList(cosubscript / !"="_tok), + construct( + "[" >> nonemptyList(cosubscript / lookAhead(space / ",]"_ch)), defaulted("," >> nonemptyList(Parser{})) / "]")) // R926 image-selector-spec -> diff --git a/flang/lib/Parser/io-parsers.cpp b/flang/lib/Parser/io-parsers.cpp --- a/flang/lib/Parser/io-parsers.cpp +++ b/flang/lib/Parser/io-parsers.cpp @@ -24,7 +24,7 @@ // R905 char-variable -> variable // "char-variable" is attempted first since it's not type constrained but // syntactically ambiguous with "file-unit-number", which is constrained. -TYPE_PARSER(construct(variable / !"="_tok) || +TYPE_PARSER(construct(variable / lookAhead(space / ",);\n"_ch)) || construct(fileUnitNumber) || construct(star)) // R1202 file-unit-number -> scalar-int-expr