[flang-commits] [PATCH] D127427: [flang][runtime] Fix overflow detection for REAL input
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jun 13 16:10:02 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c42e67bf7f5: [flang][runtime] Fix overflow detection for REAL input (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127427/new/
https://reviews.llvm.org/D127427
Files:
flang/runtime/edit-input.cpp
flang/runtime/io-stmt.h
Index: flang/runtime/io-stmt.h
===================================================================
--- flang/runtime/io-stmt.h
+++ flang/runtime/io-stmt.h
@@ -136,7 +136,7 @@
std::optional<char32_t> PrepareInput(
const DataEdit &edit, std::optional<int> &remaining) {
remaining.reset();
- if (edit.descriptor == DataEdit::ListDirected) {
+ if (edit.IsListDirected()) {
std::size_t byteCount{0};
GetNextNonBlank(byteCount);
} else {
Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -297,7 +297,9 @@
}
for (exponent = 0; next; next = io.NextInField(remaining, edit)) {
if (*next >= '0' && *next <= '9') {
- exponent = 10 * exponent + *next - '0';
+ if (exponent < 10000) {
+ exponent = 10 * exponent + *next - '0';
+ }
} else if (*next == ' ' || *next == '\t') {
if (bzMode) {
exponent = 10 * exponent;
@@ -392,7 +394,7 @@
const char *limit{str + maxConsume};
decimal::ConversionToBinaryResult<PRECISION> converted{
decimal::ConvertToBinary<PRECISION>(p, edit.modes.round, limit)};
- if (converted.flags & decimal::Invalid) {
+ if (converted.flags & (decimal::Invalid | decimal::Overflow)) {
return false;
}
if (edit.digits.value_or(0) != 0) {
@@ -428,9 +430,6 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127427.436596.patch
Type: text/x-patch
Size: 1772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220613/d8176abb/attachment.bin>
More information about the flang-commits
mailing list