Skip to content

Commit aa77cf9

Browse files
committed
[flang][runtime] Signal format error when input field width is zero
A data edit descriptor for input may not have a zero field width. Differential Revision: https://reviews.llvm.org/D127017
1 parent e5a4f73 commit aa77cf9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

flang/runtime/format-implementation.h

+5
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ DataEdit FormatControl<CONTEXT>::GetNextDataEdit(
434434
} else if (edit.descriptor != DataEdit::DefinedDerivedType) {
435435
edit.width = GetIntField(context);
436436
}
437+
if constexpr (std::is_base_of_v<InputStatementState, CONTEXT>) {
438+
if (edit.width.value_or(-1) == 0) {
439+
ReportBadFormat(context, "Input field width is zero", start);
440+
}
441+
}
437442
if (edit.descriptor != DataEdit::DefinedDerivedType && PeekNext() == '.') {
438443
++offset_;
439444
edit.digits = GetIntField(context);

0 commit comments

Comments
 (0)