[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
This commit is contained in:
Peter Klausler 2022-05-29 10:12:57 -07:00
parent e5a4f730da
commit aa77cf90aa
1 changed files with 5 additions and 0 deletions

View File

@ -434,6 +434,11 @@ DataEdit FormatControl<CONTEXT>::GetNextDataEdit(
} else if (edit.descriptor != DataEdit::DefinedDerivedType) { } else if (edit.descriptor != DataEdit::DefinedDerivedType) {
edit.width = GetIntField(context); edit.width = GetIntField(context);
} }
if constexpr (std::is_base_of_v<InputStatementState, CONTEXT>) {
if (edit.width.value_or(-1) == 0) {
ReportBadFormat(context, "Input field width is zero", start);
}
}
if (edit.descriptor != DataEdit::DefinedDerivedType && PeekNext() == '.') { if (edit.descriptor != DataEdit::DefinedDerivedType && PeekNext() == '.') {
++offset_; ++offset_;
edit.digits = GetIntField(context); edit.digits = GetIntField(context);