[flang][runtime] Signal new I/O error on floating-point input overflow

Besides raising the IEEE floating-point overflow exception, treat
a floating-point overflow on input as an I/O error catchable with
ERR=, IOSTAT=, &/or IOMSG=.

Differential Revision: https://reviews.llvm.org/D127022
This commit is contained in:
Peter Klausler 2022-06-03 13:26:28 -07:00
parent b346af6d44
commit 9c54d76251
3 changed files with 10 additions and 0 deletions

View File

@ -74,6 +74,7 @@ enum Iostat {
IostatBadWaitUnit,
IostatBOZInputOverflow,
IostatIntegerInputOverflow,
IostatRealInputOverflow,
};
const char *IostatErrorString(int);

View File

@ -428,6 +428,9 @@ static bool TryFastPathRealInput(
io.HandleRelativePosition(p - str);
// Set FP exception flags
if (converted.flags != decimal::ConversionResultFlags::Exact) {
if (converted.flags & decimal::ConversionResultFlags::Overflow) {
return false; // let slow path deal with it
}
RaiseFPExceptions(converted.flags);
}
return true;
@ -505,6 +508,10 @@ bool EditCommonRealInput(IoStatementState &io, const DataEdit &edit, void *n) {
converted.binary;
// Set FP exception flags
if (converted.flags != decimal::ConversionResultFlags::Exact) {
if (converted.flags & decimal::ConversionResultFlags::Overflow) {
io.GetIoErrorHandler().SignalError(IostatRealInputOverflow);
return false;
}
RaiseFPExceptions(converted.flags);
}
return true;

View File

@ -92,6 +92,8 @@ const char *IostatErrorString(int iostat) {
return "B/O/Z input value overflows variable";
case IostatIntegerInputOverflow:
return "Integer input value overflows variable";
case IostatRealInputOverflow:
return "Real or complex input value overflows type";
default:
return nullptr;
}