forked from OSchip/llvm-project
[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:
parent
b346af6d44
commit
9c54d76251
|
@ -74,6 +74,7 @@ enum Iostat {
|
|||
IostatBadWaitUnit,
|
||||
IostatBOZInputOverflow,
|
||||
IostatIntegerInputOverflow,
|
||||
IostatRealInputOverflow,
|
||||
};
|
||||
|
||||
const char *IostatErrorString(int);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue