Always emit the letter 'E' in list-directed REAL output;
the library was omitting it for exponents greater than 99,
as should be done for E and D formatting of large exponents
without an Ed exponent digit count.
Differential Revision: https://reviews.llvm.org/D93319
Define Fortran derived types that describe the characteristics
of derived types, and instantiations of parameterized derived
types, that are of relevance to the runtime language support
library. Define a suite of corresponding C++ structure types
for the runtime library to use to interpret instances of the
descriptions.
Create instances of these description types in Semantics as
static initializers for compiler-created objects in the scopes
that define or instantiate user derived types.
Delete obsolete code from earlier attempts to package runtime
type information.
Differential Revision: https://reviews.llvm.org/D92802
Add error reporting infrastructure and support for ALLOCATE
and DEALLOCATE statements of intrinsic types without SOURCE=
or MOLD=.
Differential revision: https://reviews.llvm.org/D91215
- Rework the host runtime table so that it is constexpr to avoid
having to construct it and to store/propagate it.
- Make the interface simpler (remove many templates and a file)
- Enable 16bits float folding using 32bits float host runtime
- Move StaticMultimapView into its own header to use it for host
folding
Reviewed By: klausler, PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D88981
MSVC does not support a distinct 80-bit extended precision
"long double" type. Rework the I/O runtime to avoid using
native C/C++ type names. Centralize the mappings between
the KIND= type parameters of REAL and their binary precisions
in the common real.h header file, and use KIND type parameter
values rather than binary precisions for clarity where
appropriate.
This patch, if successful, should obviate the need for
Differential review D88511.
(This patch anticipates a successful review of D88688, which
fixes the function that maps each kind of real to its maximum
number of significant decimal digits.)
Differential revision: https://reviews.llvm.org/D88752
The sign of the scaling factor was misinterpreted for output
as meaning what it does for input. To be correct, they
should cancel each other out.
print '(1P,F4.3)', 1. ! printed 0.1 but should print 10.0
Differential revision: https://reviews.llvm.org/D88610
The template `ListDirectedStatementState` was declared as a struct and then as a class.
Fix it so they match.
Differential Revision: https://reviews.llvm.org/D88711
Support integer and default character stop codes on PAUSE
statements. Add length argument to STOP statement with a
character stop code.
Differential revision: https://reviews.llvm.org/D88692
It turns out that unformatted fixed-size output records
do need to be padded out if short, in order to avoid a
spurious EOF crash on a short record at the end of the file.
While here in AdvanceRecord(), move the unformatted
variable-length record header/footer writing code to here
from EndIoStatement().
Differential revision: https://reviews.llvm.org/D88685
The buffer needs to be Reset() after a Flush(), since the
Flush() can be a no-op after a read->write transition.
And record numbers are 1-based, not 0-based.
This fixes a bug with rewrites of records that have been
recently read.
Differential revision: https://reviews.llvm.org/D88612
Tweak binary->decimal conversions to avoid an integer multiplication
in a hot loop to improve readability and get a minor (~5%) speed-up.
Use native integer division by constants for more readability, too,
since current build compilers seem to optimize it correctly now.
Delete the now needless temporary work-around facility in
Common/unsigned-const-division.h.
Differential revision: https://reviews.llvm.org/D88604
A WRITE to an unformatted sequential variable-length unit after
a BACKSPACE needs to forget its previous knowledge of the length
of the record that's about to be overwritten, and a BACKSPACE
after an ENDFILE or at the start of the file needs to be a no-op.
Differential revision: https://reviews.llvm.org/D88675
Don't give false positives from INQUIRE about possible
access mode changes on connected units. DIRECT and SEQUENTIAL
cannot be intermixed, apart from allowing DIRECT on a SEQUENTIAL
file with fixed-size records and positioning. Nor can
FORMATTED and UNFORMATTED be interchanged. On unconnected
files, the best that we can do is "UNKNOWN".
Differential revision: https://reviews.llvm.org/D88673
Add checking to I/O statement APIs to catch cases where the formatted
I/O data item transfer routines like OutputInteger64 are being
incorrectly used for unformatted I/O, which should use the
unformatted block or descriptor-based data item interfaces.
Differential revision: https://reviews.llvm.org/D88672
The estimation of the decimal exponent needs to allow for all
'd' of the requested significant digits.
Also accept a plus sign on a "+kP" scaling factor in a format.
Differential revision: https://reviews.llvm.org/D88618
The '/' control edit descriptor causes a runtime crash for an
external formatted sequential READ because the AdvanceRecord()
member function for external units implemented only the tasks
to finish reading the current record. Split those out into
a new FinishReadingRecord() member function, call that instead
from EndIoStatement(), and change AdvanceRecord() to both
finish reading the current record and to begin reading the next
one.
Differential revision: https://reviews.llvm.org/D88607
These types have to distinguish list-directed I/O from formatted I/O,
and the subscript incrementation call was in the formatted branch
of the if() rather than after the if().
Differential revision: https://reviews.llvm.org/D88606
The Fortran standard discusses BZ mode (treat blanks as zero digits)
explicitly in its effect on the editing of the digits prior to the
exponent part, but doesn't mention it in description of the
exponent part. Other compilers honor BZ mode in the exponent,
so we should do so too. So "1 e 1 " is 1.E11 in BZ mode.
Differential Revision: https://reviews.llvm.org/D87653
The descriptor-based I/O routine was using the size of the descriptor
rather than the size of the described data for the transfer. Fix,
and add a comment to the relevant API.
Differential Revision: https://reviews.llvm.org/D85863
Add support for OutputDescriptor() and InputDescriptor()
in the I/O runtime. Change existing scalar formatted I/O
functions to drive descriptor-based I/O routines internally.
Differential Revision: https://reviews.llvm.org/D85491
External input was detecting "end of file" conditions in
BeginExternal...Input() and BeginUnformattedInput() routines
before EnableHandlers() could have been called. Defer the
"start next record" processing to the input data item
handlers (and EndIoStatement() for when there are no data
items).
Differential Revision: https://reviews.llvm.org/D85161
Extend the raw file wrapper to get accessibility, positioning,
and size information. This is needed for INQUIRE (to follow).
Differential Revision: https://reviews.llvm.org/D85160
A comma is not required between a scale factor and a following
data edit descriptor (C1302).
Reviewed By: PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D84369
It turns out that COMPLEX formatted input needs its own runtime APIs
so that null values in list-directed input skip the entire COMPLEX
datum rather than just a real or imaginary part thereof.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D84370
When FORMAT control reaches the final parenthesis and data items
remain, we advance a record and revert to the beginning of the
FORMAT for further items. But when the FORMAT contains any
nested parenthesized group of editing descriptors, possibly
repeated, reversion must be to the beginning of the last such
top-level parenthesized group, including its repetition count.
Reviewed By: sscalpone, PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D84281
Add SetConvert() to the OPEN statement's runtime API.
Add ByteswapOption() to the main program's runtime API.
Check a $FORT_CONVERT environment variable, too, for
a swapping specifier.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D84284
Add a missing newline to IEEE FP flag formatting, and
don't neglect to emit STOP when there's no code number.
Reviewed By: tskeith
Differential Revision: https://reviews.llvm.org/D84060
Summary: For Lw output editing, emit (w-1) blanks before the T or the F.
Reviewed By: sscalpone, PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D84059
The runtime was requiring that STATUS='OLD' be explicitly specified
on an OPEN statement for a connected unit. There error should issue
only if a STATUS= other than 'OLD' is specified; an OPEN with no
STATUS= specifier is okay.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D84079
Anonymous Fortran unit files (e.g., "./fort.7") need to be created
O_RDWR so that they can be written, rewound, and read. Other
files opened with no ACTION= specifier need to set read/write
permissions based on the file, if it exists.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D84063
BeginInternalListInput and BeginInternalListOutput were missing
from the I/O API implementation; add them.
Reviewed By: PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D84066
Allow repeated nulls in list-directed input (e.g., "4*,") and
ignore excess characters in list-directed LOGICAL input after the
T or F.
Fixes FCVS test fm923.f.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D83810
I/O from/to an unopened unit number needs to open &/or create
a "fort.$UNIT" file.
Fixes FCVS test fm401.f.
Reviewed By: tskeith
Differential Revision: https://reviews.llvm.org/D83809
Ensure that external unit number hashing produces a valid
index for a negative unit number, viz. a NEWUNIT=.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D83428
Add new unit tests for external Fortran I/O that drive the
Fortran I/O runtime API from C++ and exercise basic writing
and read-back in the various combinations of access modes,
record length variability, and formatting. Sequential modes
are tested with positioning. More thorough tests written in
Fortran will follow when they can be compiled and run.
The Fortran runtime's error termination callback registration
was extended with source file and line number positions for
better failure messages in unit testing.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D83164
Complete the rework of the initial implementation of external I/O
to fix problems found in testing (tests to follow); add handlers
for hitherto unimplemented PAUSE, FLUSH, ENDFILE, BACKSPACE, and
REWIND statements.
Reviewed By: tskeith, sscalpone
Differential Revision: https://reviews.llvm.org/D83162
The per-I/O-statement state structures need to support missing
external I/O statements, and some bugs found in testing with
formatted input and record advancement are fixed. The effects
of these changes will not be visible until further patches to
the I/O API handlers are pushed.
Reviewed By: tskeith
Differential Revision: https://reviews.llvm.org/D83151
Rework initial implementation of external I/O unit operations to
fix problems exposed in unit tests (in a later patch). Add flushing.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D83147