[Flang] Trailing comma in FORMAT specifier accepted by gfortran but rejected by Flang
Flang, while compiling the program
program t
write(*,'(f3.0, )') 1.0
end program
throws this error
Unexpected ',' before ')' in format expression
write(*,'(f3.0, )') 1.0
^
While gfortran, when compiled with the flag -fdec-blank-format-item, successfully compiles the program with no errors. If the flag is not used, it emits:
write(*,'(f3.0, )') 1.0
1
Error: Missing item in format string at (1)
Should flang support this behavior similar to gfortran (-fdec-blank-format-item), or is the current rejection the intended behavior? GNU Fortran documentation mentions that a comma with no following format descriptor may be permitted with -fdec-blank-format-item as a legacy DEC extension , reference link :Commas-in-FORMAT-specifications
@llvm/issue-subscribers-flang-frontend
Author: jay0x (blazie2004)
While gfortran, when compiled with the flag -fdec-blank-format-item, successfully compiles the program with no errors. If the flag is not used, it emits:
write(*,'(f3.0, )') 1.0
1
Error: Missing item in format string at (1)
Should flang support this behavior similar to gfortran (-fdec-blank-format-item), or is the current rejection the intended behavior? GNU Fortran documentation mentions that a comma with no following format descriptor may be permitted with -fdec-blank-format-item as a legacy DEC extension , refernce link :Commas-in-FORMAT-specifications
The empty format item does nothing, so the comma can be safely and easily deleted without changing program semantics. What's the motivation for accepting it?
@blazie2004 reiterating @klausler "what is the motivation for accepting it?"
The gfortran option "-fdec-blank-format-item" dates back to gfortran 10.1. In my research I cannot find the motivation for adding this at that date. For forensics, I consulted Claude AI to find any Fortran application using this option. There was but 1 hit - a pulsar timing package named "Tempo". Researching Tempo, it has evolved over decades. I downloaded the currently available sources from Sourceforge https://sourceforge.net/projects/tempo/. Scanning those sources and configuration, there is no use of this DEC extension, and no use of this gfortran compiler option in current src tree. Further, it seemed Tempo was superceded by Tempo2 roughly 20 years ago (2006). Similarly, I downloaded Tempo2. Scanned the configure and source files for any use of this extension or the gfortran option. No use of these.
This is not to say there could be some legacy app SOMEWHERE that relies on this gfortran option. I have not found any.
Which circles back to Peter's question - "What is the motivation"? It appears there is no longer a need for this option that I can find. Do you have an example of an application requiring this gfortran option?
My question was spurred mostly by the fact that an empty format specifier has no useful purpose. Why not just delete it?
Without the strong motivation to support this, closing as "not planned".