This is an archive of the discontinued LLVM Phabricator instance.

[flang] Error recovery improvement in runtime (IOMSG=)
ClosedPublic

Authored by klausler on Mar 18 2022, 1:45 PM.

Details

Summary

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.

  1. 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.

  1. 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().)

  1. 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.

Diff Detail

Event Timeline

klausler created this revision.Mar 18 2022, 1:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2022, 1:45 PM
Herald added a subscriber: jdoerfert. · View Herald Transcript
klausler requested review of this revision.Mar 18 2022, 1:45 PM
vdonaldson accepted this revision.Mar 18 2022, 3:59 PM
This revision is now accepted and ready to land.Mar 18 2022, 3:59 PM
This revision was automatically updated to reflect the committed changes.