Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flang/docs/Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ end
* A character length specifier in a component or entity declaration
is accepted before an array specification (`ch*3(2)`) as well
as afterwards.
* A zero field width is allowed for logical formatted output (`L0`).

### Extensions supported when enabled by options

Expand Down
11 changes: 7 additions & 4 deletions flang/include/flang/Common/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,13 @@ template <typename CHAR> void FormatValidator<CHAR>::check_r(bool allowed) {
template <typename CHAR> bool FormatValidator<CHAR>::check_w() {
if (token_.kind() == TokenKind::UnsignedInteger) {
wValue_ = integerValue_;
if (wValue_ == 0 &&
(*argString_ == 'A' || *argString_ == 'L' ||
stmt_ == IoStmtKind::Read)) { // C1306, 13.7.2.1p6
ReportError("'%s' edit descriptor 'w' value must be positive");
if (wValue_ == 0) {
if (*argString_ == 'A' || stmt_ == IoStmtKind::Read) {
// C1306, 13.7.2.1p6
ReportError("'%s' edit descriptor 'w' value must be positive");
} else if (*argString_ == 'L') {
ReportWarning("'%s' edit descriptor 'w' value should be positive");
}
}
NextToken();
return true;
Expand Down
4 changes: 2 additions & 2 deletions flang/test/Semantics/io07.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
6001 format(((I0, B0)))

!ERROR: 'A' edit descriptor 'w' value must be positive
!ERROR: 'L' edit descriptor 'w' value must be positive
!WARNING: 'L' edit descriptor 'w' value should be positive
6101 format((A0), ((L0)))

!ERROR: 'L' edit descriptor 'w' value must be positive
!WARNING: 'L' edit descriptor 'w' value should be positive
6102 format((3(((L 0 0 0)))))

7001 format(17G8.1, 17G8.1e3)
Expand Down
3 changes: 1 addition & 2 deletions flang/test/Semantics/io08.f90
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@
!ERROR: 'A' edit descriptor 'w' value must be positive
write(*,'(A0)')

!ERROR: 'L' edit descriptor 'w' value must be positive
write(*,'(L0)')
write(*,'(L0)') ! warning, not error

!ERROR: Expected 'G' edit descriptor '.d' value
write(*,'(G4)')
Expand Down
2 changes: 1 addition & 1 deletion flang/unittests/Runtime/LogicalFormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TEST(IOApiTests, LogicalFormatTest) {
char buffer[bufferSize];

// Create format for all types and values to be written
const char *format{"(L,L3,I3,L2,L2,I3,L2,A3,L2,L,F4.1,L2)"};
const char *format{"(L0,L3,I3,L2,L2,I3,L2,A3,L2,L,F4.1,L2)"};
auto cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};

Expand Down
Loading