xref: /llvm-project/flang/runtime/edit-input.cpp (revision 839f0abdaaa63569d8e153b553445b6f2a8aaa0f)
1 //===-- runtime/edit-input.cpp --------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "edit-input.h"
10 #include "namelist.h"
11 #include "utf.h"
12 #include "flang/Common/real.h"
13 #include "flang/Common/uint128.h"
14 #include <algorithm>
15 #include <cfenv>
16 
17 namespace Fortran::runtime::io {
18 
19 static bool EditBOZInput(IoStatementState &io, const DataEdit &edit, void *n,
20     int base, int totalBitSize) {
21   std::optional<int> remaining;
22   std::optional<char32_t> next{io.PrepareInput(edit, remaining)};
23   common::UnsignedInt128 value{0};
24   for (; next; next = io.NextInField(remaining, edit)) {
25     char32_t ch{*next};
26     if (ch == ' ' || ch == '\t') {
27       continue;
28     }
29     int digit{0};
30     if (ch >= '0' && ch <= '1') {
31       digit = ch - '0';
32     } else if (base >= 8 && ch >= '2' && ch <= '7') {
33       digit = ch - '0';
34     } else if (base >= 10 && ch >= '8' && ch <= '9') {
35       digit = ch - '0';
36     } else if (base == 16 && ch >= 'A' && ch <= 'Z') {
37       digit = ch + 10 - 'A';
38     } else if (base == 16 && ch >= 'a' && ch <= 'z') {
39       digit = ch + 10 - 'a';
40     } else {
41       io.GetIoErrorHandler().SignalError(
42           "Bad character '%lc' in B/O/Z input field", ch);
43       return false;
44     }
45     value *= base;
46     value += digit;
47   }
48   // TODO: check for overflow
49   std::memcpy(n, &value, totalBitSize >> 3);
50   return true;
51 }
52 
53 static inline char32_t GetDecimalPoint(const DataEdit &edit) {
54   return edit.modes.editingFlags & decimalComma ? char32_t{','} : char32_t{'.'};
55 }
56 
57 // Prepares input from a field, and consumes the sign, if any.
58 // Returns true if there's a '-' sign.
59 static bool ScanNumericPrefix(IoStatementState &io, const DataEdit &edit,
60     std::optional<char32_t> &next, std::optional<int> &remaining) {
61   next = io.PrepareInput(edit, remaining);
62   bool negative{false};
63   if (next) {
64     negative = *next == '-';
65     if (negative || *next == '+') {
66       io.SkipSpaces(remaining);
67       next = io.NextInField(remaining, edit);
68     }
69   }
70   return negative;
71 }
72 
73 bool EditIntegerInput(
74     IoStatementState &io, const DataEdit &edit, void *n, int kind) {
75   RUNTIME_CHECK(io.GetIoErrorHandler(), kind >= 1 && !(kind & (kind - 1)));
76   switch (edit.descriptor) {
77   case DataEdit::ListDirected:
78     if (IsNamelistName(io)) {
79       return false;
80     }
81     break;
82   case 'G':
83   case 'I':
84     break;
85   case 'B':
86     return EditBOZInput(io, edit, n, 2, kind << 3);
87   case 'O':
88     return EditBOZInput(io, edit, n, 8, kind << 3);
89   case 'Z':
90     return EditBOZInput(io, edit, n, 16, kind << 3);
91   case 'A': // legacy extension
92     return EditCharacterInput(io, edit, reinterpret_cast<char *>(n), kind);
93   default:
94     io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
95         "Data edit descriptor '%c' may not be used with an INTEGER data item",
96         edit.descriptor);
97     return false;
98   }
99   std::optional<int> remaining;
100   std::optional<char32_t> next;
101   bool negate{ScanNumericPrefix(io, edit, next, remaining)};
102   common::UnsignedInt128 value{0};
103   bool any{negate};
104   for (; next; next = io.NextInField(remaining, edit)) {
105     char32_t ch{*next};
106     if (ch == ' ' || ch == '\t') {
107       if (edit.modes.editingFlags & blankZero) {
108         ch = '0'; // BZ mode - treat blank as if it were zero
109       } else {
110         continue;
111       }
112     }
113     int digit{0};
114     if (ch >= '0' && ch <= '9') {
115       digit = ch - '0';
116     } else {
117       io.GetIoErrorHandler().SignalError(
118           "Bad character '%lc' in INTEGER input field", ch);
119       return false;
120     }
121     value *= 10;
122     value += digit;
123     any = true;
124   }
125   if (negate) {
126     value = -value;
127   }
128   if (any || !io.GetConnectionState().IsAtEOF()) {
129     std::memcpy(n, &value, kind); // a blank field means zero
130   }
131   return any;
132 }
133 
134 // Parses a REAL input number from the input source as a normalized
135 // fraction into a supplied buffer -- there's an optional '-', a
136 // decimal point, and at least one digit.  The adjusted exponent value
137 // is returned in a reference argument.  The returned value is the number
138 // of characters that (should) have been written to the buffer -- this can
139 // be larger than the buffer size and can indicate overflow.  Replaces
140 // blanks with zeroes if appropriate.
141 static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
142     const DataEdit &edit, int &exponent) {
143   std::optional<int> remaining;
144   std::optional<char32_t> next;
145   int got{0};
146   std::optional<int> decimalPoint;
147   auto Put{[&](char ch) -> void {
148     if (got < bufferSize) {
149       buffer[got] = ch;
150     }
151     ++got;
152   }};
153   if (ScanNumericPrefix(io, edit, next, remaining)) {
154     Put('-');
155   }
156   bool bzMode{(edit.modes.editingFlags & blankZero) != 0};
157   if (!next || (!bzMode && *next == ' ')) { // empty/blank field means zero
158     remaining.reset();
159     if (!io.GetConnectionState().IsAtEOF()) {
160       Put('0');
161     }
162     return got;
163   }
164   char32_t decimal{GetDecimalPoint(edit)};
165   char32_t first{*next >= 'a' && *next <= 'z' ? *next + 'A' - 'a' : *next};
166   if (first == 'N' || first == 'I') {
167     // NaN or infinity - convert to upper case
168     // Subtle: a blank field of digits could be followed by 'E' or 'D',
169     for (; next &&
170          ((*next >= 'a' && *next <= 'z') || (*next >= 'A' && *next <= 'Z'));
171          next = io.NextInField(remaining, edit)) {
172       if (*next >= 'a' && *next <= 'z') {
173         Put(*next - 'a' + 'A');
174       } else {
175         Put(*next);
176       }
177     }
178     if (next && *next == '(') { // NaN(...)
179       while (next && *next != ')') {
180         next = io.NextInField(remaining, edit);
181       }
182     }
183     exponent = 0;
184   } else if (first == decimal || (first >= '0' && first <= '9') ||
185       (bzMode && (first == ' ' || first == '\t')) || first == 'E' ||
186       first == 'D' || first == 'Q') {
187     Put('.'); // input field is normalized to a fraction
188     auto start{got};
189     for (; next; next = io.NextInField(remaining, edit)) {
190       char32_t ch{*next};
191       if (ch == ' ' || ch == '\t') {
192         if (bzMode) {
193           ch = '0'; // BZ mode - treat blank as if it were zero
194         } else {
195           continue;
196         }
197       }
198       if (ch == '0' && got == start && !decimalPoint) {
199         // omit leading zeroes before the decimal
200       } else if (ch >= '0' && ch <= '9') {
201         Put(ch);
202       } else if (ch == decimal && !decimalPoint) {
203         // the decimal point is *not* copied to the buffer
204         decimalPoint = got - start; // # of digits before the decimal point
205       } else {
206         break;
207       }
208     }
209     if (got == start) {
210       // Nothing but zeroes and maybe a decimal point.  F'2018 requires
211       // at least one digit, but F'77 did not, and a bare "." shows up in
212       // the FCVS suite.
213       Put('0'); // emit at least one digit
214     }
215     if (next &&
216         (*next == 'e' || *next == 'E' || *next == 'd' || *next == 'D' ||
217             *next == 'q' || *next == 'Q')) {
218       // Optional exponent letter.  Blanks are allowed between the
219       // optional exponent letter and the exponent value.
220       io.SkipSpaces(remaining);
221       next = io.NextInField(remaining, edit);
222     }
223     // The default exponent is -kP, but the scale factor doesn't affect
224     // an explicit exponent.
225     exponent = -edit.modes.scale;
226     if (next &&
227         (*next == '-' || *next == '+' || (*next >= '0' && *next <= '9') ||
228             (bzMode && (*next == ' ' || *next == '\t')))) {
229       bool negExpo{*next == '-'};
230       if (negExpo || *next == '+') {
231         next = io.NextInField(remaining, edit);
232       }
233       for (exponent = 0; next; next = io.NextInField(remaining, edit)) {
234         if (*next >= '0' && *next <= '9') {
235           exponent = 10 * exponent + *next - '0';
236         } else if (bzMode && (*next == ' ' || *next == '\t')) {
237           exponent = 10 * exponent;
238         } else {
239           break;
240         }
241       }
242       if (negExpo) {
243         exponent = -exponent;
244       }
245     }
246     if (decimalPoint) {
247       exponent += *decimalPoint;
248     } else {
249       // When no decimal point (or comma) appears in the value, the 'd'
250       // part of the edit descriptor must be interpreted as the number of
251       // digits in the value to be interpreted as being to the *right* of
252       // the assumed decimal point (13.7.2.3.2)
253       exponent += got - start - edit.digits.value_or(0);
254     }
255   } else {
256     // TODO: hex FP input
257     exponent = 0;
258     return 0;
259   }
260   // Consume the trailing ')' of a list-directed or NAMELIST complex
261   // input value.
262   if (edit.descriptor == DataEdit::ListDirectedImaginaryPart) {
263     if (next && (*next == ' ' || *next == '\t')) {
264       next = io.NextInField(remaining, edit);
265     }
266     if (!next) { // NextInField fails on separators like ')'
267       std::size_t byteCount{0};
268       next = io.GetCurrentChar(byteCount);
269       if (next && *next == ')') {
270         io.HandleRelativePosition(byteCount);
271       }
272     }
273   } else if (remaining) {
274     while (next && (*next == ' ' || *next == '\t')) {
275       next = io.NextInField(remaining, edit);
276     }
277     if (next) {
278       return 0; // error: unused nonblank character in fixed-width field
279     }
280   }
281   return got;
282 }
283 
284 static void RaiseFPExceptions(decimal::ConversionResultFlags flags) {
285 #undef RAISE
286 #ifdef feraisexcept // a macro in some environments; omit std::
287 #define RAISE feraiseexcept
288 #else
289 #define RAISE std::feraiseexcept
290 #endif
291   if (flags & decimal::ConversionResultFlags::Overflow) {
292     RAISE(FE_OVERFLOW);
293   }
294   if (flags & decimal::ConversionResultFlags::Inexact) {
295     RAISE(FE_INEXACT);
296   }
297   if (flags & decimal::ConversionResultFlags::Invalid) {
298     RAISE(FE_INVALID);
299   }
300 #undef RAISE
301 }
302 
303 // If no special modes are in effect and the form of the input value
304 // that's present in the input stream is acceptable to the decimal->binary
305 // converter without modification, this fast path for real input
306 // saves time by avoiding memory copies and reformatting of the exponent.
307 template <int PRECISION>
308 static bool TryFastPathRealInput(
309     IoStatementState &io, const DataEdit &edit, void *n) {
310   if (edit.modes.editingFlags & (blankZero | decimalComma)) {
311     return false;
312   }
313   if (edit.modes.scale != 0) {
314     return false;
315   }
316   const char *str{nullptr};
317   std::size_t got{io.GetNextInputBytes(str)};
318   if (got == 0 || str == nullptr ||
319       !io.GetConnectionState().recordLength.has_value()) {
320     return false; // could not access reliably-terminated input stream
321   }
322   const char *p{str};
323   std::int64_t maxConsume{
324       std::min<std::int64_t>(got, edit.width.value_or(got))};
325   const char *limit{str + maxConsume};
326   decimal::ConversionToBinaryResult<PRECISION> converted{
327       decimal::ConvertToBinary<PRECISION>(p, edit.modes.round, limit)};
328   if (converted.flags & decimal::Invalid) {
329     return false;
330   }
331   if (edit.digits.value_or(0) != 0 &&
332       std::memchr(str, '.', p - str) == nullptr) {
333     // No explicit decimal point, and edit descriptor is Fw.d (or other)
334     // with d != 0, which implies scaling.
335     return false;
336   }
337   for (; p < limit && (*p == ' ' || *p == '\t'); ++p) {
338   }
339   if (edit.descriptor == DataEdit::ListDirectedImaginaryPart) {
340     // Need to consume a trailing ')' and any white space after
341     if (p >= limit || *p != ')') {
342       return false;
343     }
344     for (++p; p < limit && (*p == ' ' || *p == '\t'); ++p) {
345     }
346   }
347   if (edit.width && p < str + *edit.width) {
348     return false; // unconverted characters remain in fixed width field
349   }
350   // Success on the fast path!
351   *reinterpret_cast<decimal::BinaryFloatingPointNumber<PRECISION> *>(n) =
352       converted.binary;
353   io.HandleRelativePosition(p - str);
354   // Set FP exception flags
355   if (converted.flags != decimal::ConversionResultFlags::Exact) {
356     RaiseFPExceptions(converted.flags);
357   }
358   return true;
359 }
360 
361 template <int KIND>
362 bool EditCommonRealInput(IoStatementState &io, const DataEdit &edit, void *n) {
363   constexpr int binaryPrecision{common::PrecisionOfRealKind(KIND)};
364   if (TryFastPathRealInput<binaryPrecision>(io, edit, n)) {
365     return true;
366   }
367   // Fast path wasn't available or didn't work; go the more general route
368   static constexpr int maxDigits{
369       common::MaxDecimalConversionDigits(binaryPrecision)};
370   static constexpr int bufferSize{maxDigits + 18};
371   char buffer[bufferSize];
372   int exponent{0};
373   int got{ScanRealInput(buffer, maxDigits + 2, io, edit, exponent)};
374   if (got >= maxDigits + 2) {
375     io.GetIoErrorHandler().Crash("EditCommonRealInput: buffer was too small");
376     return false;
377   }
378   if (got == 0) {
379     io.GetIoErrorHandler().SignalError(IostatBadRealInput);
380     return false;
381   }
382   bool hadExtra{got > maxDigits};
383   if (exponent != 0) {
384     buffer[got++] = 'e';
385     if (exponent < 0) {
386       buffer[got++] = '-';
387       exponent = -exponent;
388     }
389     if (exponent > 9999) {
390       exponent = 9999; // will convert to +/-Inf
391     }
392     if (exponent > 999) {
393       int dig{exponent / 1000};
394       buffer[got++] = '0' + dig;
395       int rest{exponent - 1000 * dig};
396       dig = rest / 100;
397       buffer[got++] = '0' + dig;
398       rest -= 100 * dig;
399       dig = rest / 10;
400       buffer[got++] = '0' + dig;
401       buffer[got++] = '0' + (rest - 10 * dig);
402     } else if (exponent > 99) {
403       int dig{exponent / 100};
404       buffer[got++] = '0' + dig;
405       int rest{exponent - 100 * dig};
406       dig = rest / 10;
407       buffer[got++] = '0' + dig;
408       buffer[got++] = '0' + (rest - 10 * dig);
409     } else if (exponent > 9) {
410       int dig{exponent / 10};
411       buffer[got++] = '0' + dig;
412       buffer[got++] = '0' + (exponent - 10 * dig);
413     } else {
414       buffer[got++] = '0' + exponent;
415     }
416   }
417   buffer[got] = '\0';
418   const char *p{buffer};
419   decimal::ConversionToBinaryResult<binaryPrecision> converted{
420       decimal::ConvertToBinary<binaryPrecision>(p, edit.modes.round)};
421   if (hadExtra) {
422     converted.flags = static_cast<enum decimal::ConversionResultFlags>(
423         converted.flags | decimal::Inexact);
424   }
425   *reinterpret_cast<decimal::BinaryFloatingPointNumber<binaryPrecision> *>(n) =
426       converted.binary;
427   // Set FP exception flags
428   if (converted.flags != decimal::ConversionResultFlags::Exact) {
429     RaiseFPExceptions(converted.flags);
430   }
431   return true;
432 }
433 
434 template <int KIND>
435 bool EditRealInput(IoStatementState &io, const DataEdit &edit, void *n) {
436   constexpr int binaryPrecision{common::PrecisionOfRealKind(KIND)};
437   switch (edit.descriptor) {
438   case DataEdit::ListDirected:
439     if (IsNamelistName(io)) {
440       return false;
441     }
442     return EditCommonRealInput<KIND>(io, edit, n);
443   case DataEdit::ListDirectedRealPart:
444   case DataEdit::ListDirectedImaginaryPart:
445   case 'F':
446   case 'E': // incl. EN, ES, & EX
447   case 'D':
448   case 'G':
449     return EditCommonRealInput<KIND>(io, edit, n);
450   case 'B':
451     return EditBOZInput(
452         io, edit, n, 2, common::BitsForBinaryPrecision(binaryPrecision));
453   case 'O':
454     return EditBOZInput(
455         io, edit, n, 8, common::BitsForBinaryPrecision(binaryPrecision));
456   case 'Z':
457     return EditBOZInput(
458         io, edit, n, 16, common::BitsForBinaryPrecision(binaryPrecision));
459   case 'A': // legacy extension
460     return EditCharacterInput(io, edit, reinterpret_cast<char *>(n), KIND);
461   default:
462     io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
463         "Data edit descriptor '%c' may not be used for REAL input",
464         edit.descriptor);
465     return false;
466   }
467 }
468 
469 // 13.7.3 in Fortran 2018
470 bool EditLogicalInput(IoStatementState &io, const DataEdit &edit, bool &x) {
471   switch (edit.descriptor) {
472   case DataEdit::ListDirected:
473     if (IsNamelistName(io)) {
474       return false;
475     }
476     break;
477   case 'L':
478   case 'G':
479     break;
480   default:
481     io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
482         "Data edit descriptor '%c' may not be used for LOGICAL input",
483         edit.descriptor);
484     return false;
485   }
486   std::optional<int> remaining;
487   std::optional<char32_t> next{io.PrepareInput(edit, remaining)};
488   if (next && *next == '.') { // skip optional period
489     next = io.NextInField(remaining, edit);
490   }
491   if (!next) {
492     io.GetIoErrorHandler().SignalError("Empty LOGICAL input field");
493     return false;
494   }
495   switch (*next) {
496   case 'T':
497   case 't':
498     x = true;
499     break;
500   case 'F':
501   case 'f':
502     x = false;
503     break;
504   default:
505     io.GetIoErrorHandler().SignalError(
506         "Bad character '%lc' in LOGICAL input field", *next);
507     return false;
508   }
509   if (remaining) { // ignore the rest of the field
510     io.HandleRelativePosition(*remaining);
511   } else if (edit.descriptor == DataEdit::ListDirected) {
512     while (io.NextInField(remaining, edit)) { // discard rest of field
513     }
514   }
515   return true;
516 }
517 
518 // See 13.10.3.1 paragraphs 7-9 in Fortran 2018
519 template <typename CHAR>
520 static bool EditDelimitedCharacterInput(
521     IoStatementState &io, CHAR *x, std::size_t length, char32_t delimiter) {
522   bool result{true};
523   while (true) {
524     std::size_t byteCount{0};
525     auto ch{io.GetCurrentChar(byteCount)};
526     if (!ch) {
527       if (io.AdvanceRecord()) {
528         continue;
529       } else {
530         result = false; // EOF in character value
531         break;
532       }
533     }
534     io.HandleRelativePosition(byteCount);
535     if (*ch == delimiter) {
536       auto next{io.GetCurrentChar(byteCount)};
537       if (next && *next == delimiter) {
538         // Repeated delimiter: use as character value
539         io.HandleRelativePosition(byteCount);
540       } else {
541         break; // closing delimiter
542       }
543     }
544     if (length > 0) {
545       *x++ = *ch;
546       --length;
547     }
548   }
549   std::fill_n(x, length, ' ');
550   return result;
551 }
552 
553 template <typename CHAR>
554 static bool EditListDirectedCharacterInput(
555     IoStatementState &io, CHAR *x, std::size_t length, const DataEdit &edit) {
556   std::size_t byteCount{0};
557   auto ch{io.GetCurrentChar(byteCount)};
558   if (ch && (*ch == '\'' || *ch == '"')) {
559     io.HandleRelativePosition(byteCount);
560     return EditDelimitedCharacterInput(io, x, length, *ch);
561   }
562   if (IsNamelistName(io) || io.GetConnectionState().IsAtEOF()) {
563     return false;
564   }
565   // Undelimited list-directed character input: stop at a value separator
566   // or the end of the current record.  Subtlety: the "remaining" count
567   // here is a dummy that's used to avoid the interpretation of separators
568   // in NextInField.
569   std::optional<int> remaining{maxUTF8Bytes};
570   while (std::optional<char32_t> next{io.NextInField(remaining, edit)}) {
571     switch (*next) {
572     case ' ':
573     case '\t':
574     case ',':
575     case ';':
576     case '/':
577       remaining = 0; // value separator: stop
578       break;
579     default:
580       *x++ = *next;
581       --length;
582       remaining = maxUTF8Bytes;
583     }
584   }
585   std::fill_n(x, length, ' ');
586   return true;
587 }
588 
589 template <typename CHAR>
590 bool EditCharacterInput(
591     IoStatementState &io, const DataEdit &edit, CHAR *x, std::size_t length) {
592   switch (edit.descriptor) {
593   case DataEdit::ListDirected:
594     return EditListDirectedCharacterInput(io, x, length, edit);
595   case 'A':
596   case 'G':
597     break;
598   default:
599     io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
600         "Data edit descriptor '%c' may not be used with a CHARACTER data item",
601         edit.descriptor);
602     return false;
603   }
604   const ConnectionState &connection{io.GetConnectionState()};
605   if (connection.IsAtEOF()) {
606     return false;
607   }
608   std::size_t remaining{length};
609   if (edit.width && *edit.width > 0) {
610     remaining = *edit.width;
611   }
612   // When the field is wider than the variable, we drop the leading
613   // characters.  When the variable is wider than the field, there's
614   // trailing padding.
615   const char *input{nullptr};
616   std::size_t ready{0};
617   bool hitEnd{false};
618   // Skip leading bytes.
619   // These bytes don't count towards INQUIRE(IOLENGTH=).
620   std::size_t skip{remaining > length ? remaining - length : 0};
621   // Transfer payload bytes; these do count.
622   while (remaining > 0) {
623     if (ready == 0) {
624       ready = io.GetNextInputBytes(input);
625       if (ready == 0) {
626         hitEnd = true;
627         break;
628       }
629     }
630     std::size_t chunk;
631     bool skipping{skip > 0};
632     if (connection.isUTF8) {
633       chunk = MeasureUTF8Bytes(*input);
634       if (skipping) {
635         --skip;
636       } else if (auto ucs{DecodeUTF8(input)}) {
637         *x++ = *ucs;
638         --length;
639       } else if (chunk == 0) {
640         // error recovery: skip bad encoding
641         chunk = 1;
642       }
643       --remaining;
644     } else {
645       if (skipping) {
646         chunk = std::min<std::size_t>(skip, ready);
647         skip -= chunk;
648       } else {
649         chunk = std::min<std::size_t>(remaining, ready);
650         std::memcpy(x, input, chunk);
651         x += chunk;
652         length -= chunk;
653       }
654       remaining -= chunk;
655     }
656     input += chunk;
657     if (!skipping) {
658       io.GotChar(chunk);
659     }
660     io.HandleRelativePosition(chunk);
661     ready -= chunk;
662   }
663   // Pad the remainder of the input variable, if any.
664   std::fill_n(x, length, ' ');
665   if (hitEnd) {
666     io.CheckForEndOfRecord(); // signal any needed error
667   }
668   return true;
669 }
670 
671 template bool EditRealInput<2>(IoStatementState &, const DataEdit &, void *);
672 template bool EditRealInput<3>(IoStatementState &, const DataEdit &, void *);
673 template bool EditRealInput<4>(IoStatementState &, const DataEdit &, void *);
674 template bool EditRealInput<8>(IoStatementState &, const DataEdit &, void *);
675 template bool EditRealInput<10>(IoStatementState &, const DataEdit &, void *);
676 // TODO: double/double
677 template bool EditRealInput<16>(IoStatementState &, const DataEdit &, void *);
678 
679 template bool EditCharacterInput(
680     IoStatementState &, const DataEdit &, char *, std::size_t);
681 template bool EditCharacterInput(
682     IoStatementState &, const DataEdit &, char16_t *, std::size_t);
683 template bool EditCharacterInput(
684     IoStatementState &, const DataEdit &, char32_t *, std::size_t);
685 
686 } // namespace Fortran::runtime::io
687