File tree 4 files changed +22
-9
lines changed
flang-rt/include/flang-rt/runtime
4 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -427,15 +427,24 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
427
427
} else {
428
428
--chars;
429
429
}
430
- EmitAscii (context, format_ + start, chars);
430
+ if constexpr (std::is_base_of_v<InputStatementState, CONTEXT>) {
431
+ context.HandleRelativePosition (chars);
432
+ } else {
433
+ EmitAscii (context, format_ + start, chars);
434
+ }
431
435
} else if (ch == ' H' ) {
432
436
// 9HHOLLERITH
433
437
if (!repeat || *repeat < 1 || offset_ + *repeat > formatLength_) {
434
438
ReportBadFormat (context, " Invalid width on Hollerith in FORMAT" ,
435
439
maybeReversionPoint);
436
440
return 0 ;
437
441
}
438
- EmitAscii (context, format_ + offset_, static_cast <std::size_t >(*repeat));
442
+ if constexpr (std::is_base_of_v<InputStatementState, CONTEXT>) {
443
+ context.HandleRelativePosition (static_cast <std::size_t >(*repeat));
444
+ } else {
445
+ EmitAscii (
446
+ context, format_ + offset_, static_cast <std::size_t >(*repeat));
447
+ }
439
448
offset_ += *repeat;
440
449
} else if (ch >= ' A' && ch <= ' Z' ) {
441
450
int start{offset_ - 1 };
Original file line number Diff line number Diff line change 424
424
* A zero field width is allowed for logical formatted output (` L0 ` ).
425
425
* ` OPEN(..., FORM='BINARY') ` is accepted as a legacy synonym for
426
426
the standard ` OPEN(..., FORM='UNFORMATTED', ACCESS='STREAM') ` .
427
+ * A character string edit descriptor is allowed in an input format
428
+ with an optional compilation-time warning. When executed, it
429
+ is treated as an 'nX' positioning control descriptor that skips
430
+ over the same number of characters, without comparison.
427
431
428
432
### Extensions supported when enabled by options
429
433
Original file line number Diff line number Diff line change @@ -430,11 +430,11 @@ template <typename CHAR> void FormatValidator<CHAR>::NextToken() {
430
430
}
431
431
}
432
432
SetLength ();
433
- if (stmt_ == IoStmtKind::Read &&
434
- previousToken_.kind () != TokenKind::DT) { // 13.3.2p6
435
- ReportError (" String edit descriptor in READ format expression" );
436
- } else if (token_.kind () != TokenKind::String) {
433
+ if (token_.kind () != TokenKind::String) {
437
434
ReportError (" Unterminated string" );
435
+ } else if (stmt_ == IoStmtKind::Read &&
436
+ previousToken_.kind () != TokenKind::DT) { // 13.3.2p6
437
+ ReportWarning (" String edit descriptor in READ format expression" );
438
438
}
439
439
break ;
440
440
default :
Original file line number Diff line number Diff line change 1
- ! RUN: %python %S/test_errors.py %s %flang_fc1
2
- ! ERROR : String edit descriptor in READ format expression
1
+ ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2
+ ! WARNING : String edit descriptor in READ format expression
3
3
read (* ,' ("abc")' )
4
4
5
- ! ERROR: String edit descriptor in READ format expression
5
+ ! ERROR: Unterminated string
6
6
! ERROR: Unterminated format expression
7
7
read (* ,' ("abc)' )
8
8
You can’t perform that action at this time.
0 commit comments