aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Parser/io-parsers.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-02-21[Flang] Give a more specific error message for expressions where an IO Unit ↵Andre Kuhlenschmidt1-1/+5
is expected (#126970) This PR fixes #125446 by specializing the error message that is generated when an arbitrary expression is used as an IO Unit. See the tests for specific examples, but the general gist is that if you use a non-variable expression as the IO unit argument to a read or write, you now get a more specific error message indicating the the expression could have been a scalar integer expression or character variable.
2024-08-26[flang] Fix parser crash (#105875)Peter Klausler1-1/+2
The production for a bare file unit number in an I/O statement checks that the scalar integer expression isn't followed by "=", in order to disambiguate FLUSHN from FLUSHN=1, and to not treat a control specifier keyword as an integer expression. The implementation of this check used !"="_tok, which has the side effect of producing no error message; this can lead to a parsing crash later when a failed parse of an erroneous program is found to have produced no errors. Rewrite as a lookAhead call for those characters that acually can follow a bare unit number. Fixes https://github.com/llvm/llvm-project/issues/105779.
2023-07-21[flang] Emit just one warning for a bad format edit descriptorPeter Klausler1-22/+20
An attempt to use an edit descriptor (other than A or L) in a FORMAT statement without arequired 'w' width will elicit warnings from both the parser and the I/O checker in semantics. Remove the warning from the parser. Differential Revision: https://reviews.llvm.org/D155977
2023-05-31[flang] CUDA Fortran - part 1/5: parsingPeter Klausler1-5/+0
Begin upstreaming of CUDA Fortran support in LLVM Flang. This first patch implements parsing for CUDA Fortran syntax, including: - a new LanguageFeature enum value for CUDA Fortran - driver change to enable that feature for *.cuf and *.CUF source files - parse tree representation of CUDA Fortran syntax - dumping and unparsing of the parse tree - the actual parsers for CUDA Fortran syntax - prescanning support for !@CUF and !$CUF - basic sanity testing via unparsing and parse tree dumps ... along with any minimized changes elsewhere to make these work, mostly no-op cases in common::visitors instances in semantics and lowering to allow them to compile in the face of new types in variant<> instances in the parse tree. Because CUDA Fortran allows the kernel launch chevron syntax ("call foo<<<blocks, threads>>>()") only on CALL statements and not on function references, the parse tree nodes for CallStmt, FunctionReference, and their shared Call were rearranged a bit; this caused a fair amount of one-line changes in many files. More patches will follow that implement CUDA Fortran in the symbol table and name resolution, and then semantic checking. Differential Revision: https://reviews.llvm.org/D150159
2022-10-29[flang] Improve error recovery for bad/missing construct END statementsPeter Klausler1-1/+0
When a multi-statement construct should end with a particular END statement like "END SELECT", and that construct's END statement is missing or unrecognizable, the error recovery productions should not misinterpret a program unit END statement that follows and consume it as a misspelled construct END statement. Doing so leads to cascading errors or a failed parse. Differential Revision: https://reviews.llvm.org/D136896
2022-07-06[flang] Avoid spurious warnings in pedantic mode from FORMAT itemsPeter Klausler1-61/+67
In free form source, pedantic mode will elicit portability warnings about missing spaces when a token string ends with a character that can be in an identifier and there is no space between that last token character and a following character that can also be part of an identifier. This behavior doesn't really work well for the token strings that are parsed for edit descriptors in FORMAT statements. For example, the 'F' in FORMAT(F7.3) is followed by a digit, but obviously no space is necessary. Free form or not, FORMATs are their own odd little world. This patch adds trailing blanks to these FORMAT edit descriptor token parsers to disable the missing space check, and extends the documentation for token string parsing to explain why this technique works. Differential Revision: https://reviews.llvm.org/D129023
2022-03-18[flang] Add explanatory messages to grammar for language extensionsPeter Klausler1-14/+28
Extend "extension<LanguageFeature>()" to incorporate an explanatory message better than the current generic "nonstandard usage:". Differential Revision: https://reviews.llvm.org/D122035
2021-02-01[flang] Fix parsing of WRITE(I+J) with more accurate look-aheadpeter klausler1-1/+1
The parsing of I/O units uses look-ahead to discriminate between keywords, variables and expressions as part of distinguishing internal from external I/O. The look-ahead was inaccurate for variables that appear as the initial parts of expressions. Differential Revision: https://reviews.llvm.org/D95743
2020-11-12[flang] Recognize END FILE as ENDFILE in free form sourcepeter klausler1-1/+1
The ENDFILE statement may be spelled as two words. Differential revision: https://reviews.llvm.org/D91377
2020-10-30[flang] Detect and rewrite ambiguous READ(CVAR)[,item-list]peter klausler1-0/+4
READ(CVAR)[,item-list] with a character variable CVAR could be parsed as an unformatted READ from an internal unit or as a formatted READ from the default external unit with a needlessly parenthesized variable format. We parse it as the former, but Fortran doesn't have unformatted internal I/O. Differential revision: https://reviews.llvm.org/D90493
2020-09-02[flang] Implement nonstandard OPEN statement CARRIAGECONTROL specifierpeter klausler1-3/+14
Differential Revision: https://reviews.llvm.org/D87052
2020-04-03[flang] Process names in ASSIGN and assigned GOTOpeter klausler1-1/+2
Allow ASSIGNed integer variables as formats Address review comment Original-commit: flang-compiler/f18@361a151508b4a1940fc0669dead180be67964d8d Reviewed-on: https://github.com/flang-compiler/f18/pull/1099
2020-03-28[flang] Reformat with latest clang-format and .clang-formatTim Keith1-4/+4
Original-commit: flang-compiler/f18@9fe84f45d7fd685051004678d6b5775dcc4c6f8f Reviewed-on: https://github.com/flang-compiler/f18/pull/1094
2020-02-25[flang] [LLVMify F18] Compiler module folders should have capitalised names ↵CarolineConcatto1-0/+664
(flang-compiler/f18#980) This patch renames the modules in f18 to use a capital letter in the module name Signed-off-by: Caroline Concatto <caroline.concatto@arm.com> Original-commit: flang-compiler/f18@d2eb7a1c443d1539ef12b6f027074a0eb15b1ea0 Reviewed-on: https://github.com/flang-compiler/f18/pull/980