Skip to content

Commit

Permalink
[flang][runtime] Fix input of NAN(...) on non-fast path
Browse files Browse the repository at this point in the history
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
  • Loading branch information
klausler committed May 9, 2022
1 parent 09fc685 commit 2f31b4b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions flang/runtime/edit-input.cpp
Expand Up @@ -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') ||
Expand Down

0 comments on commit 2f31b4b

Please sign in to comment.