Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2022-04-27 02:49:29 +0300
committerPeter Klausler <pklausler@nvidia.com>2022-05-09 22:38:31 +0300
commit2f31b4b10a1ab3ec937fbbead55b66b8dfbb0934 (patch)
tree633f1d4b6e69e2b849781bcd5dd8135d2e97d464 /flang
parent09fc685ce6808ae34de8e235bad686252eef3812 (diff)
[flang][runtime] Fix input of NAN(...) on non-fast path
The closing parenthesis needs to be consumed when a NaN with parenthesized (ignored) information is read on the real input path that preprocesses input characters before passing them to the decimal-to-binary converter. Differential Revision: https://reviews.llvm.org/D125048
Diffstat (limited to 'flang')
-rw-r--r--flang/runtime/edit-input.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index 304394577861..b694749ccc22 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -217,17 +217,19 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
if (next && *next == '(') { // NaN(...)
Put('(');
int depth{1};
- do {
+ while (true) {
next = io.NextInField(remaining, edit);
- if (!next) {
+ if (depth == 0) {
break;
+ } else if (!next) {
+ return 0; // error
} else if (*next == '(') {
++depth;
} else if (*next == ')') {
--depth;
}
Put(*next);
- } while (depth > 0);
+ }
}
exponent = 0;
} else if (first == decimal || (first >= '0' && first <= '9') ||