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     bool anyDigit{false};
190     for (; next; next = io.NextInField(remaining, edit)) {
191       char32_t ch{*next};
192       if (ch == ' ' || ch == '\t') {
193         if (bzMode) {
194           ch = '0'; // BZ mode - treat blank as if it were zero
195         } else {
196           continue;
197         }
198       }
199       if (ch == '0' && got == start && !decimalPoint) {
200         anyDigit = true;
201         // omit leading zeroes before the decimal
202       } else if (ch >= '0' && ch <= '9') {
203         anyDigit = true;
204         Put(ch);
205       } else if (ch == decimal && !decimalPoint) {
206         // the decimal point is *not* copied to the buffer
207         decimalPoint = got - start; // # of digits before the decimal point
208       } else {
209         break;
210       }
211     }
212     if (got == start) {
213       if (anyDigit) {
214         Put('0'); // emit at least one digit
215       } else {
216         return 0; // no digits, invalid input
217       }
218     }
219     if (next &&
220         (*next == 'e' || *next == 'E' || *next == 'd' || *next == 'D' ||
221             *next == 'q' || *next == 'Q')) {
222       // Optional exponent letter.  Blanks are allowed between the
223       // optional exponent letter and the exponent value.
224       io.SkipSpaces(remaining);
225       next = io.NextInField(remaining, edit);
226     }
227     // The default exponent is -kP, but the scale factor doesn't affect
228     // an explicit exponent.
229     exponent = -edit.modes.scale;
230     if (next &&
231         (*next == '-' || *next == '+' || (*next >= '0' && *next <= '9') ||
232             (bzMode && (*next == ' ' || *next == '\t')))) {
233       bool negExpo{*next == '-'};
234       if (negExpo || *next == '+') {
235         next = io.NextInField(remaining, edit);
236       }
237       for (exponent = 0; next; next = io.NextInField(remaining, edit)) {
238         if (*next >= '0' && *next <= '9') {
239           exponent = 10 * exponent + *next - '0';
240         } else if (bzMode && (*next == ' ' || *next == '\t')) {
241           exponent = 10 * exponent;
242         } else {
243           break;
244         }
245       }
246       if (negExpo) {
247         exponent = -exponent;
248       }
249     }
250     if (decimalPoint) {
251       exponent += *decimalPoint;
252     } else {
253       // When no decimal point (or comma) appears in the value, the 'd'
254       // part of the edit descriptor must be interpreted as the number of
255       // digits in the value to be interpreted as being to the *right* of
256       // the assumed decimal point (13.7.2.3.2)
257       exponent += got - start - edit.digits.value_or(0);
258     }
259   } else {
260     // TODO: hex FP input
261     exponent = 0;
262     return 0;
263   }
264   // Consume the trailing ')' of a list-directed or NAMELIST complex
265   // input value.
266   if (edit.descriptor == DataEdit::ListDirectedImaginaryPart) {
267     if (next && (*next == ' ' || *next == '\t')) {
268       next = io.NextInField(remaining, edit);
269     }
270     if (!next) { // NextInField fails on separators like ')'
271       std::size_t byteCount{0};
272       next = io.GetCurrentChar(byteCount);
273       if (next && *next == ')') {
274         io.HandleRelativePosition(byteCount);
275       }
276     }
277   } else if (remaining) {
278     while (next && (*next == ' ' || *next == '\t')) {
279       next = io.NextInField(remaining, edit);
280     }
281     if (next) {
282       return 0; // error: unused nonblank character in fixed-width field
283     }
284   }
285   return got;
286 }
287 
288 static void RaiseFPExceptions(decimal::ConversionResultFlags flags) {
289 #undef RAISE
290 #ifdef feraisexcept // a macro in some environments; omit std::
291 #define RAISE feraiseexcept
292 #else
293 #define RAISE std::feraiseexcept
294 #endif
295   if (flags & decimal::ConversionResultFlags::Overflow) {
296     RAISE(FE_OVERFLOW);
297   }
298   if (flags & decimal::ConversionResultFlags::Inexact) {
299     RAISE(FE_INEXACT);
300   }
301   if (flags & decimal::ConversionResultFlags::Invalid) {
302     RAISE(FE_INVALID);
303   }
304 #undef RAISE
305 }
306 
307 // If no special modes are in effect and the form of the input value
308 // that's present in the input stream is acceptable to the decimal->binary
309 // converter without modification, this fast path for real input
310 // saves time by avoiding memory copies and reformatting of the exponent.
311 template <int PRECISION>
312 static bool TryFastPathRealInput(
313     IoStatementState &io, const DataEdit &edit, void *n) {
314   if (edit.modes.editingFlags & (blankZero | decimalComma)) {
315     return false;
316   }
317   if (edit.modes.scale != 0) {
318     return false;
319   }
320   const char *str{nullptr};
321   std::size_t got{io.GetNextInputBytes(str)};
322   if (got == 0 || str == nullptr ||
323       !io.GetConnectionState().recordLength.has_value()) {
324     return false; // could not access reliably-terminated input stream
325   }
326   const char *p{str};
327   std::int64_t maxConsume{
328       std::min<std::int64_t>(got, edit.width.value_or(got))};
329   const char *limit{str + maxConsume};
330   decimal::ConversionToBinaryResult<PRECISION> converted{
331       decimal::ConvertToBinary<PRECISION>(p, edit.modes.round, limit)};
332   if (converted.flags & decimal::Invalid) {
333     return false;
334   }
335   if (edit.digits.value_or(0) != 0 &&
336       std::memchr(str, '.', p - str) == nullptr) {
337     // No explicit decimal point, and edit descriptor is Fw.d (or other)
338     // with d != 0, which implies scaling.
339     return false;
340   }
341   for (; p < limit && (*p == ' ' || *p == '\t'); ++p) {
342   }
343   if (edit.descriptor == DataEdit::ListDirectedImaginaryPart) {
344     // Need to consume a trailing ')' and any white space after
345     if (p >= limit || *p != ')') {
346       return false;
347     }
348     for (++p; p < limit && (*p == ' ' || *p == '\t'); ++p) {
349     }
350   }
351   if (edit.width && p < str + *edit.width) {
352     return false; // unconverted characters remain in fixed width field
353   }
354   // Success on the fast path!
355   *reinterpret_cast<decimal::BinaryFloatingPointNumber<PRECISION> *>(n) =
356       converted.binary;
357   io.HandleRelativePosition(p - str);
358   // Set FP exception flags
359   if (converted.flags != decimal::ConversionResultFlags::Exact) {
360     RaiseFPExceptions(converted.flags);
361   }
362   return true;
363 }
364 
365 template <int KIND>
366 bool EditCommonRealInput(IoStatementState &io, const DataEdit &edit, void *n) {
367   constexpr int binaryPrecision{common::PrecisionOfRealKind(KIND)};
368   if (TryFastPathRealInput<binaryPrecision>(io, edit, n)) {
369     return true;
370   }
371   // Fast path wasn't available or didn't work; go the more general route
372   static constexpr int maxDigits{
373       common::MaxDecimalConversionDigits(binaryPrecision)};
374   static constexpr int bufferSize{maxDigits + 18};
375   char buffer[bufferSize];
376   int exponent{0};
377   int got{ScanRealInput(buffer, maxDigits + 2, io, edit, exponent)};
378   if (got >= maxDigits + 2) {
379     io.GetIoErrorHandler().Crash("EditCommonRealInput: buffer was too small");
380     return false;
381   }
382   if (got == 0) {
383     io.GetIoErrorHandler().SignalError(IostatBadRealInput);
384     return false;
385   }
386   bool hadExtra{got > maxDigits};
387   if (exponent != 0) {
388     buffer[got++] = 'e';
389     if (exponent < 0) {
390       buffer[got++] = '-';
391       exponent = -exponent;
392     }
393     if (exponent > 9999) {
394       exponent = 9999; // will convert to +/-Inf
395     }
396     if (exponent > 999) {
397       int dig{exponent / 1000};
398       buffer[got++] = '0' + dig;
399       int rest{exponent - 1000 * dig};
400       dig = rest / 100;
401       buffer[got++] = '0' + dig;
402       rest -= 100 * dig;
403       dig = rest / 10;
404       buffer[got++] = '0' + dig;
405       buffer[got++] = '0' + (rest - 10 * dig);
406     } else if (exponent > 99) {
407       int dig{exponent / 100};
408       buffer[got++] = '0' + dig;
409       int rest{exponent - 100 * dig};
410       dig = rest / 10;
411       buffer[got++] = '0' + dig;
412       buffer[got++] = '0' + (rest - 10 * dig);
413     } else if (exponent > 9) {
414       int dig{exponent / 10};
415       buffer[got++] = '0' + dig;
416       buffer[got++] = '0' + (exponent - 10 * dig);
417     } else {
418       buffer[got++] = '0' + exponent;
419     }
420   }
421   buffer[got] = '\0';
422   const char *p{buffer};
423   decimal::ConversionToBinaryResult<binaryPrecision> converted{
424       decimal::ConvertToBinary<binaryPrecision>(p, edit.modes.round)};
425   if (hadExtra) {
426     converted.flags = static_cast<enum decimal::ConversionResultFlags>(
427         converted.flags | decimal::Inexact);
428   }
429   *reinterpret_cast<decimal::BinaryFloatingPointNumber<binaryPrecision> *>(n) =
430       converted.binary;
431   // Set FP exception flags
432   if (converted.flags != decimal::ConversionResultFlags::Exact) {
433     RaiseFPExceptions(converted.flags);
434   }
435   return true;
436 }
437 
438 template <int KIND>
439 bool EditRealInput(IoStatementState &io, const DataEdit &edit, void *n) {
440   constexpr int binaryPrecision{common::PrecisionOfRealKind(KIND)};
441   switch (edit.descriptor) {
442   case DataEdit::ListDirected:
443     if (IsNamelistName(io)) {
444       return false;
445     }
446     return EditCommonRealInput<KIND>(io, edit, n);
447   case DataEdit::ListDirectedRealPart:
448   case DataEdit::ListDirectedImaginaryPart:
449   case 'F':
450   case 'E': // incl. EN, ES, & EX
451   case 'D':
452   case 'G':
453     return EditCommonRealInput<KIND>(io, edit, n);
454   case 'B':
455     return EditBOZInput(
456         io, edit, n, 2, common::BitsForBinaryPrecision(binaryPrecision));
457   case 'O':
458     return EditBOZInput(
459         io, edit, n, 8, common::BitsForBinaryPrecision(binaryPrecision));
460   case 'Z':
461     return EditBOZInput(
462         io, edit, n, 16, common::BitsForBinaryPrecision(binaryPrecision));
463   case 'A': // legacy extension
464     return EditCharacterInput(io, edit, reinterpret_cast<char *>(n), KIND);
465   default:
466     io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
467         "Data edit descriptor '%c' may not be used for REAL input",
468         edit.descriptor);
469     return false;
470   }
471 }
472 
473 // 13.7.3 in Fortran 2018
474 bool EditLogicalInput(IoStatementState &io, const DataEdit &edit, bool &x) {
475   switch (edit.descriptor) {
476   case DataEdit::ListDirected:
477     if (IsNamelistName(io)) {
478       return false;
479     }
480     break;
481   case 'L':
482   case 'G':
483     break;
484   default:
485     io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
486         "Data edit descriptor '%c' may not be used for LOGICAL input",
487         edit.descriptor);
488     return false;
489   }
490   std::optional<int> remaining;
491   std::optional<char32_t> next{io.PrepareInput(edit, remaining)};
492   if (next && *next == '.') { // skip optional period
493     next = io.NextInField(remaining, edit);
494   }
495   if (!next) {
496     io.GetIoErrorHandler().SignalError("Empty LOGICAL input field");
497     return false;
498   }
499   switch (*next) {
500   case 'T':
501   case 't':
502     x = true;
503     break;
504   case 'F':
505   case 'f':
506     x = false;
507     break;
508   default:
509     io.GetIoErrorHandler().SignalError(
510         "Bad character '%lc' in LOGICAL input field", *next);
511     return false;
512   }
513   if (remaining) { // ignore the rest of the field
514     io.HandleRelativePosition(*remaining);
515   } else if (edit.descriptor == DataEdit::ListDirected) {
516     while (io.NextInField(remaining, edit)) { // discard rest of field
517     }
518   }
519   return true;
520 }
521 
522 // See 13.10.3.1 paragraphs 7-9 in Fortran 2018
523 template <typename CHAR>
524 static bool EditDelimitedCharacterInput(
525     IoStatementState &io, CHAR *x, std::size_t length, char32_t delimiter) {
526   bool result{true};
527   while (true) {
528     std::size_t byteCount{0};
529     auto ch{io.GetCurrentChar(byteCount)};
530     if (!ch) {
531       if (io.AdvanceRecord()) {
532         continue;
533       } else {
534         result = false; // EOF in character value
535         break;
536       }
537     }
538     io.HandleRelativePosition(byteCount);
539     if (*ch == delimiter) {
540       auto next{io.GetCurrentChar(byteCount)};
541       if (next && *next == delimiter) {
542         // Repeated delimiter: use as character value
543         io.HandleRelativePosition(byteCount);
544       } else {
545         break; // closing delimiter
546       }
547     }
548     if (length > 0) {
549       *x++ = *ch;
550       --length;
551     }
552   }
553   std::fill_n(x, length, ' ');
554   return result;
555 }
556 
557 template <typename CHAR>
558 static bool EditListDirectedCharacterInput(
559     IoStatementState &io, CHAR *x, std::size_t length, const DataEdit &edit) {
560   std::size_t byteCount{0};
561   auto ch{io.GetCurrentChar(byteCount)};
562   if (ch && (*ch == '\'' || *ch == '"')) {
563     io.HandleRelativePosition(byteCount);
564     return EditDelimitedCharacterInput(io, x, length, *ch);
565   }
566   if (IsNamelistName(io) || io.GetConnectionState().IsAtEOF()) {
567     return false;
568   }
569   // Undelimited list-directed character input: stop at a value separator
570   // or the end of the current record.  Subtlety: the "remaining" count
571   // here is a dummy that's used to avoid the interpretation of separators
572   // in NextInField.
573   std::optional<int> remaining{maxUTF8Bytes};
574   while (std::optional<char32_t> next{io.NextInField(remaining, edit)}) {
575     switch (*next) {
576     case ' ':
577     case '\t':
578     case ',':
579     case ';':
580     case '/':
581       remaining = 0; // value separator: stop
582       break;
583     default:
584       *x++ = *next;
585       --length;
586       remaining = maxUTF8Bytes;
587     }
588   }
589   std::fill_n(x, length, ' ');
590   return true;
591 }
592 
593 template <typename CHAR>
594 bool EditCharacterInput(
595     IoStatementState &io, const DataEdit &edit, CHAR *x, std::size_t length) {
596   switch (edit.descriptor) {
597   case DataEdit::ListDirected:
598     return EditListDirectedCharacterInput(io, x, length, edit);
599   case 'A':
600   case 'G':
601     break;
602   default:
603     io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
604         "Data edit descriptor '%c' may not be used with a CHARACTER data item",
605         edit.descriptor);
606     return false;
607   }
608   const ConnectionState &connection{io.GetConnectionState()};
609   if (connection.IsAtEOF()) {
610     return false;
611   }
612   std::size_t remaining{length};
613   if (edit.width && *edit.width > 0) {
614     remaining = *edit.width;
615   }
616   // When the field is wider than the variable, we drop the leading
617   // characters.  When the variable is wider than the field, there's
618   // trailing padding.
619   const char *input{nullptr};
620   std::size_t ready{0};
621   bool hitEnd{false};
622   // Skip leading bytes.
623   // These bytes don't count towards INQUIRE(IOLENGTH=).
624   std::size_t skip{remaining > length ? remaining - length : 0};
625   // Transfer payload bytes; these do count.
626   while (remaining > 0) {
627     if (ready == 0) {
628       ready = io.GetNextInputBytes(input);
629       if (ready == 0) {
630         hitEnd = true;
631         break;
632       }
633     }
634     std::size_t chunk;
635     bool skipping{skip > 0};
636     if (connection.isUTF8) {
637       chunk = MeasureUTF8Bytes(*input);
638       if (skipping) {
639         --skip;
640       } else if (auto ucs{DecodeUTF8(input)}) {
641         *x++ = *ucs;
642         --length;
643       } else if (chunk == 0) {
644         // error recovery: skip bad encoding
645         chunk = 1;
646       }
647       --remaining;
648     } else {
649       if (skipping) {
650         chunk = std::min<std::size_t>(skip, ready);
651         skip -= chunk;
652       } else {
653         chunk = std::min<std::size_t>(remaining, ready);
654         std::memcpy(x, input, chunk);
655         x += chunk;
656         length -= chunk;
657       }
658       remaining -= chunk;
659     }
660     input += chunk;
661     if (!skipping) {
662       io.GotChar(chunk);
663     }
664     io.HandleRelativePosition(chunk);
665     ready -= chunk;
666   }
667   // Pad the remainder of the input variable, if any.
668   std::fill_n(x, length, ' ');
669   if (hitEnd) {
670     io.CheckForEndOfRecord(); // signal any needed error
671   }
672   return true;
673 }
674 
675 template bool EditRealInput<2>(IoStatementState &, const DataEdit &, void *);
676 template bool EditRealInput<3>(IoStatementState &, const DataEdit &, void *);
677 template bool EditRealInput<4>(IoStatementState &, const DataEdit &, void *);
678 template bool EditRealInput<8>(IoStatementState &, const DataEdit &, void *);
679 template bool EditRealInput<10>(IoStatementState &, const DataEdit &, void *);
680 // TODO: double/double
681 template bool EditRealInput<16>(IoStatementState &, const DataEdit &, void *);
682 
683 template bool EditCharacterInput(
684     IoStatementState &, const DataEdit &, char *, std::size_t);
685 template bool EditCharacterInput(
686     IoStatementState &, const DataEdit &, char16_t *, std::size_t);
687 template bool EditCharacterInput(
688     IoStatementState &, const DataEdit &, char32_t *, std::size_t);
689 
690 } // namespace Fortran::runtime::io
691