llvm-project/flang/unittests
Jean Perier c58c64d05c [flang] Add runtime API to catch unit number out of range
Unit numbers must fit on a default integer. It is however possible that
the user provides the unit number in UNIT with a wider integer type.
In such case, lowering was previously silently narrowing
the value and passing the result to the BeginXXX runtime entry points.
Cases where the conversion caused overflow were not reported/caught.
Most existing compilers catch these errors and raise an IO error.
Add a CheckUnitNumberInRange runtime API to do the same in f18.

This runtime API has its own error management interface (i.e., does not
use GetIoMsg, EndIo, and EnableHandlers) because the usual error
management requires BeginXXX to be called to set up the error
management. But in this case, the BeginXXX cannot be called since
the bad unit number that would be provided to it overflew (and in the worst
case scenario, the narrowed value could point to a different valid unit
already in use). Hence I decided to make an API that must be called
before the BeginXXX and should trigger the whole BeginXXX/.../EndIoStatement
to be skipped in case the unit number is too big and the user enabled
error recovery.

Note that CheckUnitNumberInRange accepts negative numbers (as long as
they can fit on a default integer), because unit numbers may be negative
if they were created by NEWUNIT.

Differential Revision: https://reviews.llvm.org/D123157
2022-04-06 15:38:13 +02:00
..
Common [flang] Allow more concurrently open NEWUNIT= values, with recycling 2022-02-28 16:13:22 -08:00
Decimal [flang] Make flang build compatible with LLVM dylib 2020-10-14 14:27:25 +02:00
Evaluate [flang] Remove incorrect unit test 2021-10-04 18:27:14 -07:00
Frontend [flang][driver] Add support for -S and implement -c/-emit-obj 2022-03-09 15:48:09 +00:00
Optimizer [mlir] Move the Builtin FuncOp to the Func dialect 2022-03-16 17:07:03 -07:00
Runtime [flang] Add runtime API to catch unit number out of range 2022-04-06 15:38:13 +02:00
CMakeLists.txt [flang] Allow more concurrently open NEWUNIT= values, with recycling 2022-02-28 16:13:22 -08:00