Some refactoring and related fixes for more accurate user program error recovery in the I/O runtime, especially for error recovery with IOMSG= character values. 1) Move any work in an EndIoStatement() implementation that may raise an error into a new CompleteOperation() member function. This allows error handling APIs like GetIoMsg() to complete a pending I/O statement and harvest any errors that may result. 2) Move the pending error code from ErroneousIoStatementState to a new pendingError_ data member in IoErrorHandler. This allows IoErrorHandler::InError() to return a correct result when there is a pending error that will be recovered from so that I/O list data transfers don't crash in the meantime. 3) Don't create and leak a unit for a failed OPEN(NEWUNIT=n) with error recovery, and don't modify 'n'. (Depends on changes to API call ordering in lowering, in a separate patch; code was added to ensure that OPEN statement control list specifiers, e.g. SetFile(), must be passed before GetNewUnit().) 4) Fix the code that calls a form of strerror to fill an IOMSG= variable so that it actually works for Fortran's character type: blank fill with no null or newline termination. Differential Revision: https://reviews.llvm.org/D122036
4.0 KiB
4.0 KiB