Skip to content

Commit cfa032c

Browse files
committed
[flang] Emit just one warning for a bad format edit descriptor
An attempt to use an edit descriptor (other than A or L) in a FORMAT statement without arequired 'w' width will elicit warnings from both the parser and the I/O checker in semantics. Remove the warning from the parser. Differential Revision: https://reviews.llvm.org/D155977
1 parent b2d76a0 commit cfa032c

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

flang/include/flang/Common/format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ template <typename CHAR> bool FormatValidator<CHAR>::check_w() {
471471
NextToken();
472472
return true;
473473
}
474-
if (*argString_ != 'A') {
474+
if (*argString_ != 'A' && *argString_ != 'L') {
475475
ReportWarning("Expected '%s' edit descriptor 'w' value"); // C1306
476476
}
477477
return false;

flang/lib/Parser/io-parsers.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -601,28 +601,26 @@ TYPE_PARSER(construct<format::IntrinsicTypeDataEditDesc>(
601601
"A " >> pure(format::IntrinsicTypeDataEditDesc::Kind::A), maybe(width),
602602
noInt, noInt) ||
603603
// PGI/Intel extension: omitting width (and all else that follows)
604-
extension<LanguageFeature::AbbreviatedEditDescriptor>(
605-
"nonstandard usage: abbreviated edit descriptor"_port_en_US,
606-
construct<format::IntrinsicTypeDataEditDesc>(
607-
"I " >> pure(format::IntrinsicTypeDataEditDesc::Kind::I) ||
608-
("B "_tok / !letter /* don't occlude BN & BZ */) >>
609-
pure(format::IntrinsicTypeDataEditDesc::Kind::B) ||
610-
"O " >> pure(format::IntrinsicTypeDataEditDesc::Kind::O) ||
611-
"Z " >> pure(format::IntrinsicTypeDataEditDesc::Kind::Z) ||
612-
"F " >> pure(format::IntrinsicTypeDataEditDesc::Kind::F) ||
613-
("D "_tok / !letter /* don't occlude DT, DC, & DP */) >>
614-
pure(format::IntrinsicTypeDataEditDesc::Kind::D) ||
615-
"E " >>
616-
("N " >>
617-
pure(format::IntrinsicTypeDataEditDesc::Kind::EN) ||
618-
"S " >>
619-
pure(format::IntrinsicTypeDataEditDesc::Kind::ES) ||
620-
"X " >>
621-
pure(format::IntrinsicTypeDataEditDesc::Kind::EX) ||
622-
pure(format::IntrinsicTypeDataEditDesc::Kind::E)) ||
623-
"G " >> pure(format::IntrinsicTypeDataEditDesc::Kind::G) ||
624-
"L " >> pure(format::IntrinsicTypeDataEditDesc::Kind::L),
625-
noInt, noInt, noInt)))
604+
// Parse them just to get them to the I/O checker in semantics;
605+
// they are not supported by the runtime.
606+
extension<LanguageFeature::AbbreviatedEditDescriptor>(construct<
607+
format::IntrinsicTypeDataEditDesc>(
608+
"I " >> pure(format::IntrinsicTypeDataEditDesc::Kind::I) ||
609+
("B "_tok / !letter /* don't occlude BN & BZ */) >>
610+
pure(format::IntrinsicTypeDataEditDesc::Kind::B) ||
611+
"O " >> pure(format::IntrinsicTypeDataEditDesc::Kind::O) ||
612+
"Z " >> pure(format::IntrinsicTypeDataEditDesc::Kind::Z) ||
613+
"F " >> pure(format::IntrinsicTypeDataEditDesc::Kind::F) ||
614+
("D "_tok / !letter /* don't occlude DT, DC, & DP */) >>
615+
pure(format::IntrinsicTypeDataEditDesc::Kind::D) ||
616+
"E " >>
617+
("N " >> pure(format::IntrinsicTypeDataEditDesc::Kind::EN) ||
618+
"S " >> pure(format::IntrinsicTypeDataEditDesc::Kind::ES) ||
619+
"X " >> pure(format::IntrinsicTypeDataEditDesc::Kind::EX) ||
620+
pure(format::IntrinsicTypeDataEditDesc::Kind::E)) ||
621+
"G " >> pure(format::IntrinsicTypeDataEditDesc::Kind::G) ||
622+
"L " >> pure(format::IntrinsicTypeDataEditDesc::Kind::L),
623+
noInt, noInt, noInt)))
626624

627625
// R1307 data-edit-desc (part 2 of 2)
628626
// R1312 v -> [sign] digit-string

0 commit comments

Comments
 (0)