From 690de85ed8e953e476154ced21c9ffe12917a548 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Sat, 11 Jun 2022 07:09:20 -0700 Subject: [PATCH] [flang][runtime] Better error message for mis-ASSIGN'ed FORMAT When an I/O data transfer statement uses an ASSIGN'ed FORMAT that has not been ASSIGN'ed to a FORMAT statement, the runtime receives a zero-length format string. Distinguish this case from the general error message about missing parentheses. Differential Revision: https://reviews.llvm.org/D127797 --- flang/runtime/format.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/flang/runtime/format.h b/flang/runtime/format.h index 56aa86b..40a0f30 100644 --- a/flang/runtime/format.h +++ b/flang/runtime/format.h @@ -124,8 +124,13 @@ private: 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_++]; -- 2.7.4