[flang-commits] [PATCH] D127022: [flang][runtime] Signal new I/O error on floating-point input overflow
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Jun 3 15:55:56 PDT 2022
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
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=.
https://reviews.llvm.org/D127022
Files:
flang/include/flang/Runtime/iostat.h
flang/runtime/edit-input.cpp
flang/runtime/iostat.cpp
Index: flang/runtime/iostat.cpp
===================================================================
--- flang/runtime/iostat.cpp
+++ flang/runtime/iostat.cpp
@@ -92,6 +92,8 @@
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;
}
Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -428,6 +428,9 @@
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 @@
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;
Index: flang/include/flang/Runtime/iostat.h
===================================================================
--- flang/include/flang/Runtime/iostat.h
+++ flang/include/flang/Runtime/iostat.h
@@ -74,6 +74,7 @@
IostatBadWaitUnit,
IostatBOZInputOverflow,
IostatIntegerInputOverflow,
+ IostatRealInputOverflow,
};
const char *IostatErrorString(int);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127022.434180.patch
Type: text/x-patch
Size: 1697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220603/f7f1e3e9/attachment-0001.bin>
More information about the flang-commits
mailing list