diff --git a/flang/runtime/format.h b/flang/runtime/format.h --- a/flang/runtime/format.h +++ b/flang/runtime/format.h @@ -124,8 +124,13 @@ CharType GetNextChar(IoErrorHandler &handler) { SkipBlanks(); if (offset_ >= formatLength_) { - handler.SignalError( - IostatErrorInFormat, "FORMAT missing at least one ')'"); + if (formatLength_ == 0) { + handler.SignalError( + IostatErrorInFormat, "Empty or badly assigned FORMAT"); + } else { + handler.SignalError( + IostatErrorInFormat, "FORMAT missing at least one ')'"); + } return '\n'; } return format_[offset_++];