2020-09-10 23:04:37 +05:30
|
|
|
<!--===- docs/Extensions.md
|
|
|
|
|
|
|
|
|
|
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
|
2020-09-11 14:17:19 +01:00
|
|
|
# Fortran Extensions supported by Flang
|
|
|
|
|
|
2023-09-25 14:02:39 +02:00
|
|
|
```{contents}
|
|
|
|
|
---
|
|
|
|
|
local:
|
|
|
|
|
---
|
2020-09-11 14:17:19 +01:00
|
|
|
```
|
|
|
|
|
|
2018-07-17 16:58:21 -07:00
|
|
|
As a general principle, this compiler will accept by default and
|
|
|
|
|
without complaint many legacy features, extensions to the standard
|
|
|
|
|
language, and features that have been deleted from the standard,
|
|
|
|
|
so long as the recognition of those features would not cause a
|
|
|
|
|
standard-conforming program to be rejected or misinterpreted.
|
2018-03-20 10:59:07 -07:00
|
|
|
|
2018-07-17 16:58:21 -07:00
|
|
|
Other non-standard features, which do conflict with the current
|
|
|
|
|
standard specification of the Fortran programming language, are
|
|
|
|
|
accepted if enabled by command-line options.
|
|
|
|
|
|
2020-09-11 14:17:19 +01:00
|
|
|
## Intentional violations of the standard
|
|
|
|
|
|
2019-12-19 19:13:16 -08:00
|
|
|
* Scalar `INTEGER` actual argument expressions (not variables!)
|
|
|
|
|
are converted to the kinds of scalar `INTEGER` dummy arguments
|
|
|
|
|
when the interface is explicit and the kinds differ.
|
|
|
|
|
This conversion allows the results of the intrinsics like
|
2020-01-03 16:32:23 -08:00
|
|
|
`SIZE` that (as mentioned below) may return non-default
|
2019-12-19 19:13:16 -08:00
|
|
|
`INTEGER` results by default to be passed. A warning is
|
2021-10-19 11:34:57 -07:00
|
|
|
emitted when truncation is possible. These conversions
|
|
|
|
|
are not applied in calls to non-intrinsic generic procedures.
|
2020-01-13 14:30:31 -08:00
|
|
|
* We are not strict on the contents of `BLOCK DATA` subprograms
|
|
|
|
|
so long as they contain no executable code, no internal subprograms,
|
|
|
|
|
and allocate no storage outside a named `COMMON` block. (C1415)
|
[flang] runtime: fix problems with I/O around EOF & delimited characters
When a WRITE overwrites an endfile record, we need to forget
that there was an endfile record. When doing a BACKSPACE
after an explicit ENDFILE statement, the position afterwards
must be upon the endfile record.
Attempts to join list-directed delimited character input across
record boundaries was due to a bad reading of the standard
and has been deleted, now that the requirements are better understood.
This problem would cause a read attempt past EOF if a delimited
character input value was at the end of a record.
It turns out that delimited list-directed (and NAMELIST) character
output is required to emit contiguous doubled instances of the
delimiter character when it appears in the output value. When
fixed-size records are being emitted, as is the case with internal
output, this is not possible when the problematic character falls
on the last position of a record. No two other Fortran compilers
do the same thing in this situation so there is no good precedent
to follow.
Because it seems least wrong, with this patch we now emit one copy
of the delimiter as the last character of the current record and
another as the first character of the next record. (The
second-least-wrong alternative might be to flag a runtime error,
but that seems harsh since it's not an explicit error in the standard,
and the output may not have to be usable later as input anyway.)
Consequently, the output is not suitable for use as list-directed or
NAMELIST input.
If a later standard were to clarify this case, this behavior will of
course change as needed to conform.
Differential Revision: https://reviews.llvm.org/D106695
2021-07-22 09:47:37 -07:00
|
|
|
* Delimited list-directed (and NAMELIST) character output is required
|
|
|
|
|
to emit contiguous doubled instances of the delimiter character
|
|
|
|
|
when it appears in the output value. When fixed-size records
|
|
|
|
|
are being emitted, as is the case with internal output, this
|
|
|
|
|
is not possible when the problematic character falls on the last
|
|
|
|
|
position of a record. No two other Fortran compilers do the same
|
|
|
|
|
thing in this situation so there is no good precedent to follow.
|
|
|
|
|
Because it seems least wrong, we emit one copy of the delimiter as
|
|
|
|
|
the last character of the current record and another as the first
|
|
|
|
|
character of the next record. (The second-least-wrong alternative
|
|
|
|
|
might be to flag a runtime error, but that seems harsh since it's
|
|
|
|
|
not an explicit error in the standard, and the output may not have
|
|
|
|
|
to be usable later as input anyway.)
|
|
|
|
|
Consequently, the output is not suitable for use as list-directed or
|
|
|
|
|
NAMELIST input. If a later standard were to clarify this case, this
|
|
|
|
|
behavior will change as needed to conform.
|
|
|
|
|
```
|
|
|
|
|
character(11) :: buffer(3)
|
|
|
|
|
character(10) :: quotes = '""""""""""'
|
|
|
|
|
write(buffer,*,delim="QUOTE") quotes
|
|
|
|
|
print "('>',a10,'<')", buffer
|
|
|
|
|
end
|
|
|
|
|
```
|
[flang] Extension: reduced scope for some implied DO loop indices
The index of an implied DO loop in a DATA statement or array
constructor is defined by Fortran 2018 to have scope over its
implied DO loop. This definition is unfortunate, because it
requires the implied DO loop's bounds expressions to be in the
scope of the index variable. Consequently, in code like
integer, parameter :: j = 5
real, save :: a(5) = [(j, j=1, j)]
the upper bound of the loop is a reference to the index variable,
not the parameter in the enclosing scope.
This patch limits the scope of the index variable to the "body"
of the implied DO loop as one would naturally expect, with a warning.
I would have preferred to make this a hard error, but most Fortran
compilers treat this case as f18 now does. If the standard
were to be fixed, the warning could be made optional.
Differential Revision: https://reviews.llvm.org/D108595
2021-08-20 15:18:21 -07:00
|
|
|
* The name of the control variable in an implied DO loop in an array
|
|
|
|
|
constructor or DATA statement has a scope over the value-list only,
|
|
|
|
|
not the bounds of the implied DO loop. It is not advisable to use
|
|
|
|
|
an object of the same name as the index variable in a bounds
|
|
|
|
|
expression, but it will work, instead of being needlessly undefined.
|
2021-10-06 14:03:48 -07:00
|
|
|
* If both the `COUNT=` and the `COUNT_MAX=` optional arguments are
|
|
|
|
|
present on the same call to the intrinsic subroutine `SYSTEM_CLOCK`,
|
|
|
|
|
we require that their types have the same integer kind, since the
|
[flang] Use full result range for clock_gettime implementation of SYSTEM_CLOCK
Update the primary clock_gettime implementation of SYSTEM_CLOCK to use
the full range of values, dependent on the type kind of the requested
result. Counts/sec and count max for supported kinds become:
kind counts/sec count max
1 10 127
2 1000 32767
4 1000 2147483647
8 1000000000 9223372036854775807
16 1000000000 9223372036854775807
The secondary "fallback" implementation is not changed.
Real valued COUNT_RATE arguments are not changed.
The test program below has calls for kinds 1, 2, 4, 8, 16. Support for
these types varies by compiler. The code as given can be restricted to
accommodate these variations, with results shown below.
subroutine c
integer(1) c1, r1, m1
integer(2) c2, r2, m2
integer(4) c4, r4, m4
integer(8) c8, r8, m8
integer(16) c16, r16, m16
print*
print '(a5,3a22)', 'kind', 'counts/sec', 'count max', 'count'
print*
call system_clock(c1, r1, m1)
print '(i5,3i22)', 1, r1, m1, c1
call system_clock(c2, r2, m2)
print '(i5,3i22)', 2, r2, m2, c2
call system_clock(c4, r4, m4)
print '(i5,3i22)', 4, r4, m4, c4
call system_clock(c8, r8, m8)
print '(i5,3i22)', 8, r8, m8, c8
call system_clock(c16, r16, m16)
print '(i5,3i22)', 16, r16, m16, c16
end
subroutine k(j)
j = 0
do i=1,1000000000
j = j + i
enddo
end
program p
do i=1,1 ! increase loop count to check for (kind=1) wraparound
call k(j)
call c
enddo
end
=== flang output without change (last column counts vary per run) ===
kind counts/sec count max count
1 -24 127 83
2 1000 290 211
4 1000 290 211
8 1000000000 290448383 211631452
16 1000000000 290448383 211633853
=== flang output with change (last column counts vary per run) ===
1 10 127 21
2 1000 32767 2100
4 1000 2147483647 2100
8 1000000000 9223372036854775807 2100183374
16 1000000000 9223372036854775807 2100185353
Other compilers; kind support varies (last column counts vary per run).
Test and ouput modified to avoid crashes and normalize results.
Some negative values indicate unsupported kinds; others are bugs.
kind counts/sec count max count
1 0 0 -127
2 0 0 -32767
4 1000 2147483647 69271692
8 1000000000 9223372036854775807 69271692353290
16 1000000000 9223372036854775807 69271692354794
=======
1 10 127 0
2 1000 32767 0
4 1000000 2147483647 0
8 10000000 9223372036854775807 9
=======
1 0 0 -127
2 1000 32767 3263
4 10000 2147483647 1788192630
8 1000000 9223372036854775807 1649443459263095
=======
1 -24 -1 36
2 1000 -1 -10716
4 1000 2147483647 176018980
8 1000 9223372036854775807 1649443460644
=======
2 100 28799 23080
4 100 8639999 4285480
8 100 8639999 4285480
16 100 8639999 4285480
=======
1 -24 -1 4
2 1000 23551 -26108
4 1000 86399999 67541508
8 1000000 9223372036854775807 1649443541508087
2022-04-12 10:26:14 -07:00
|
|
|
kind of these arguments is used to select the clock rate. In common
|
|
|
|
|
with some other compilers, the clock rate varies from tenths of a
|
|
|
|
|
second to nanoseconds depending on argument kind and platform support.
|
2022-03-09 13:43:54 -08:00
|
|
|
* If a dimension of a descriptor has zero extent in a call to
|
|
|
|
|
`CFI_section`, `CFI_setpointer` or `CFI_allocate`, the lower
|
|
|
|
|
bound on that dimension will be set to 1 for consistency with
|
|
|
|
|
the `LBOUND()` intrinsic function.
|
2022-05-24 15:06:12 -07:00
|
|
|
* `-2147483648_4` is, strictly speaking, a non-conforming literal
|
|
|
|
|
constant on a machine with 32-bit two's-complement integers as
|
|
|
|
|
kind 4, because the grammar of Fortran expressions parses it as a
|
|
|
|
|
negation of a literal constant, not a negative literal constant.
|
|
|
|
|
This compiler accepts it with a portability warning.
|
2023-02-02 12:11:01 -08:00
|
|
|
* Construct names like `loop` in `loop: do j=1,n` are defined to
|
|
|
|
|
be "local identifiers" and should be distinct in the "inclusive
|
|
|
|
|
scope" -- i.e., not scoped by `BLOCK` constructs.
|
|
|
|
|
As most (but not all) compilers implement `BLOCK` scoping of construct
|
|
|
|
|
names, so does f18, with a portability warning.
|
2023-02-17 16:48:25 -08:00
|
|
|
* 15.6.4 paragraph 2 prohibits an implicitly typed statement function
|
|
|
|
|
from sharing the same name as a symbol in its scope's host, if it
|
|
|
|
|
has one.
|
|
|
|
|
We accept this usage with a portability warning.
|
2023-04-01 14:05:06 -07:00
|
|
|
* A module name from a `USE` statement can also be used as a
|
|
|
|
|
non-global name in the same scope. This is not conforming,
|
|
|
|
|
but it is useful and unambiguous.
|
2023-03-30 13:34:32 -07:00
|
|
|
* The argument to `RANDOM_NUMBER` may not be an assumed-size array.
|
2023-11-13 15:14:05 -08:00
|
|
|
* `NULL()` without `MOLD=` is not allowed to be associated as an
|
|
|
|
|
actual argument corresponding to an assumed-rank dummy argument;
|
|
|
|
|
its rank in the called procedure would not be well-defined.
|
2024-01-15 10:50:40 -08:00
|
|
|
* When an index variable of a `FORALL` or `DO CONCURRENT` is present
|
|
|
|
|
in the enclosing scope, and the construct does not have an explicit
|
|
|
|
|
type specification for its index variables, some weird restrictions
|
|
|
|
|
in F'2023 subclause 19.4 paragraphs 6 & 8 should apply. Since this
|
|
|
|
|
compiler properly scopes these names, violations of these restrictions
|
|
|
|
|
elicit only portability warnings by default.
|
2024-01-15 11:48:36 -08:00
|
|
|
* The standard defines the intrinsic functions `MOD` and `MODULO`
|
|
|
|
|
for real arguments using expressions in terms of `AINT` and `FLOOR`.
|
|
|
|
|
These definitions yield fairly poor results due to floating-point
|
|
|
|
|
cancellation, and every Fortran compiler (including this one)
|
|
|
|
|
uses better algorithms.
|
[flang] Turn "error" cases into warning for "indistinguishable" specific procedures (#79621)
When a generic procedure interface, either declared or the result of
merging two use-associated generics, has two specific procedures
that are not distinguishable according to the rules in F'2023
subclause 15.4.3.4.5, emit a portability warning rather than a
hard error message. The rules in that subclause are not adequate
to detect pairs of specific procedures that admit an ambiguous
reference, as demonstrated by a case that arose in pFUnit. Further,
these distinguishability checks, even if sufficient to the task
of detecting pairs of specifics capable of ambiguous references,
should only apply to pairs where *every* reference would have to
be ambiguous -- and this can and is validated at every reference
anyway. Last, only XLF enforces these incomplete and needless
distinguishability rules -- every other compiler seems to just
check that each procedure reference resolves to exactly one
specific procedure.
If the standard were to complete lose subclause 15.4.3.4.5 and
its related note (C.11.6) -- which admits that the rules are
incomplete! -- and simply require that each generic procedure
reference resolve unambiguously to exactly one specific, nobody
would miss them. This patch changes this compiler to give them
lip service when requested, but they are now otherwise ignored.
2024-01-29 14:36:37 -08:00
|
|
|
* The rules for pairwise distinguishing the specific procedures of a
|
|
|
|
|
generic interface are inadequate, as admitted in note C.11.6 of F'2023.
|
|
|
|
|
Generic interfaces whose specific procedures can be easily proven by
|
|
|
|
|
hand to be pairwise distinct (i.e., no ambiguous reference is possible)
|
|
|
|
|
appear in real applications, but are still non-conforming under the
|
|
|
|
|
incomplete tests in F'2023 15.4.3.4.5.
|
|
|
|
|
These cases are compiled with optional portability warnings.
|
2024-05-09 11:04:50 -07:00
|
|
|
* `PROCEDURE(), BIND(C) :: PROC` is not conforming, as there is no
|
|
|
|
|
procedure interface. This compiler accepts it, since there is otherwise
|
|
|
|
|
no way to declare an interoperable dummy procedure with an arbitrary
|
|
|
|
|
interface like `void (*)()`.
|
2024-06-03 13:46:31 -07:00
|
|
|
* `PURE` functions are allowed to have dummy arguments that are
|
|
|
|
|
neither `INTENT(IN)` nor `VALUE`, similar to `PURE` subroutines,
|
|
|
|
|
with a warning.
|
|
|
|
|
This enables atomic memory operations to be naturally represented
|
|
|
|
|
as `PURE` functions, which allows their use in parallel constructs
|
|
|
|
|
and `DO CONCURRENT`.
|
2024-06-03 14:02:07 -07:00
|
|
|
* A non-definable actual argument, including the case of a vector
|
|
|
|
|
subscript, may be associated with an `ASYNCHRONOUS` or `VOLATILE`
|
2025-04-28 20:34:17 -04:00
|
|
|
dummy argument, F'2023 15.5.2.5 p21 notwithstanding.
|
2024-06-03 14:02:07 -07:00
|
|
|
The effects of these attributes are scoped over the lifetime of
|
|
|
|
|
the procedure reference, and they can by added by internal subprograms
|
|
|
|
|
and `BLOCK` constructs within the procedure.
|
|
|
|
|
Further, a dummy argument can acquire the `ASYNCHRONOUS` attribute
|
|
|
|
|
implicitly simply appearing in an asynchronous data transfer statement,
|
|
|
|
|
without the attribute being visible in the procedure's explicit
|
|
|
|
|
interface.
|
2024-07-18 15:59:24 -07:00
|
|
|
* When the name of an extended derived type's base type is the
|
|
|
|
|
result of `USE` association with renaming, the name of the extended
|
|
|
|
|
derived type's parent component is the new name by which the base
|
|
|
|
|
is known in the scope of the extended derived type, not the original.
|
|
|
|
|
This interpretation has usability advantages and is what six other
|
|
|
|
|
Fortran compilers do, but is not conforming now that J3 approved an
|
|
|
|
|
"interp" in June 2024 to the contrary.
|
2025-02-04 09:54:33 -05:00
|
|
|
* When an Arm processor raises an `ieee_overflow` or `ieee_underflow`
|
|
|
|
|
exception, the `ieee_inexact` exception is also raised. This happens
|
|
|
|
|
for a call to `ieee_set_flag` as well as for floating point expression
|
|
|
|
|
evaluation.
|
2024-12-23 09:30:45 -05:00
|
|
|
* Arm has processors that allow a user to control what happens when an
|
|
|
|
|
arithmetic exception is signaled, as well as processors that do not
|
|
|
|
|
have this capability. An Arm executable will run on either type of
|
|
|
|
|
processor, so it is effectively unknown at compile time whether or
|
|
|
|
|
not this support will be available at runtime. The standard requires
|
2025-02-27 14:57:10 -05:00
|
|
|
that a call to intrinsic module procedure `ieee_support_halting` with
|
2024-12-23 09:30:45 -05:00
|
|
|
a constant argument has a compile time constant result in `constant
|
|
|
|
|
expression` and `specification expression` contexts. In compilations
|
|
|
|
|
where this information is not known at compile time, f18 generates code
|
|
|
|
|
to determine the absence or presence of this capability at runtime.
|
2025-02-27 14:57:10 -05:00
|
|
|
A call to `ieee_support_halting` in contexts that the standard requires
|
|
|
|
|
to be constant will generate a compilation error. `ieee_support_standard`
|
|
|
|
|
depends in part on `ieee_support_halting`, so this also applies to
|
|
|
|
|
`ieee_support_standard` calls.
|
2025-05-13 07:48:30 -07:00
|
|
|
* F'2023 constraint C7108 prohibits the use of a structure constructor
|
|
|
|
|
that could also be interpreted as a generic function reference.
|
|
|
|
|
No other Fortran compiler enforces C7108 (to our knowledge);
|
|
|
|
|
they all resolve the ambiguity by interpreting the call as a function
|
|
|
|
|
reference. We do the same, with a portability warning.
|
2025-06-04 09:23:34 -07:00
|
|
|
* An override for an inaccessible procedure binding works only within
|
|
|
|
|
the same module; other apparent overrides of inaccessible bindings
|
|
|
|
|
are actually new bindings of the same name.
|
|
|
|
|
In the case of `DEFERRED` bindings in an `ABSTRACT` derived type,
|
|
|
|
|
however, overrides are necessary, so they are permitted for inaccessible
|
|
|
|
|
bindings with an optional warning.
|
2019-07-08 10:44:14 -07:00
|
|
|
|
2020-09-11 14:17:19 +01:00
|
|
|
## Extensions, deletions, and legacy features supported by default
|
|
|
|
|
|
2018-03-20 10:59:07 -07:00
|
|
|
* Tabs in source
|
|
|
|
|
* `<>` as synonym for `.NE.` and `/=`
|
|
|
|
|
* `$` and `@` as legal characters in names
|
|
|
|
|
* Initialization in type declaration statements using `/values/`
|
2025-01-08 10:56:03 +01:00
|
|
|
* Saved variables without explicit or default initializers are zero initialized,
|
|
|
|
|
except for scalar variables from the main program that are not explicitly
|
|
|
|
|
initialized or marked with an explicit SAVE attribute (these variables may be
|
|
|
|
|
placed on the stack by flang and not zero initialized). It is not advised to
|
|
|
|
|
rely on this extension in new code.
|
2023-10-02 09:53:09 +02:00
|
|
|
* In a saved entity of a type with a default initializer, components without default
|
|
|
|
|
values are zero initialized.
|
2018-03-20 10:59:07 -07:00
|
|
|
* Kind specification with `*`, e.g. `REAL*4`
|
2022-04-06 14:00:40 -07:00
|
|
|
* `DOUBLE COMPLEX` as a synonym for `COMPLEX(KIND(0.D0))` --
|
|
|
|
|
but not when spelled `TYPE(DOUBLECOMPLEX)`.
|
2018-03-20 10:59:07 -07:00
|
|
|
* Signed complex literal constants
|
2021-12-17 16:48:16 -08:00
|
|
|
* DEC `STRUCTURE`, `RECORD`, with '%FILL'; but `UNION`, and `MAP`
|
|
|
|
|
are not yet supported throughout compilation, and elicit a
|
|
|
|
|
"not yet implemented" message.
|
2018-03-20 10:59:07 -07:00
|
|
|
* Structure field access with `.field`
|
2022-04-06 14:00:40 -07:00
|
|
|
* `BYTE` as synonym for `INTEGER(KIND=1)`; but not when spelled `TYPE(BYTE)`.
|
2022-05-28 00:27:59 +02:00
|
|
|
* When kind-param is used for REAL literals, allow a matching exponent letter
|
2018-03-20 10:59:07 -07:00
|
|
|
* Quad precision REAL literals with `Q`
|
|
|
|
|
* `X` prefix/suffix as synonym for `Z` on hexadecimal literals
|
|
|
|
|
* `B`, `O`, `Z`, and `X` accepted as suffixes as well as prefixes
|
2023-03-29 00:38:18 +08:00
|
|
|
* Support for using bare `L` in FORMAT statement
|
2018-03-20 10:59:07 -07:00
|
|
|
* Triplets allowed in array constructors
|
|
|
|
|
* `%LOC`, `%VAL`, and `%REF`
|
|
|
|
|
* Leading comma allowed before I/O item list
|
|
|
|
|
* Empty parentheses allowed in `PROGRAM P()`
|
|
|
|
|
* Missing parentheses allowed in `FUNCTION F`
|
2019-07-01 13:22:22 -07:00
|
|
|
* Cray based `POINTER(p,x)` and `LOC()` intrinsic (with `%LOC()` as
|
|
|
|
|
an alias)
|
2018-07-17 16:58:21 -07:00
|
|
|
* Arithmetic `IF`. (Which branch should NaN take? Fall through?)
|
2018-03-20 10:59:07 -07:00
|
|
|
* `ASSIGN` statement, assigned `GO TO`, and assigned format
|
|
|
|
|
* `PAUSE` statement
|
|
|
|
|
* Hollerith literals and edit descriptors
|
|
|
|
|
* `NAMELIST` allowed in the execution part
|
|
|
|
|
* Omitted colons on type declaration statements with attributes
|
|
|
|
|
* COMPLEX constructor expression, e.g. `(x+y,z)`
|
|
|
|
|
* `+` and `-` before all primary expressions, e.g. `x*-y`
|
|
|
|
|
* `.NOT. .NOT.` accepted
|
|
|
|
|
* `NAME=` as synonym for `FILE=`
|
|
|
|
|
* Data edit descriptors without width or other details
|
|
|
|
|
* `D` lines in fixed form as comments or debug code
|
2020-09-02 10:37:48 -07:00
|
|
|
* `CARRIAGECONTROL=` on the OPEN and INQUIRE statements
|
2019-03-22 15:08:16 -07:00
|
|
|
* `CONVERT=` on the OPEN and INQUIRE statements
|
|
|
|
|
* `DISPOSE=` on the OPEN and INQUIRE statements
|
2018-07-12 15:32:31 -07:00
|
|
|
* Leading semicolons are ignored before any statement that
|
|
|
|
|
could have a label
|
2018-07-17 16:58:21 -07:00
|
|
|
* The character `&` in column 1 in fixed form source is a variant form
|
|
|
|
|
of continuation line.
|
2019-02-15 12:20:30 -08:00
|
|
|
* Character literals as elements of an array constructor without an explicit
|
|
|
|
|
type specifier need not have the same length; the longest literal determines
|
|
|
|
|
the length parameter of the implicit type, not the first.
|
2019-03-14 14:51:40 -07:00
|
|
|
* Outside a character literal, a comment after a continuation marker (&)
|
|
|
|
|
need not begin with a comment marker (!).
|
2025-02-28 10:18:37 +09:00
|
|
|
* Classic C-style `/*comments*/` are skipped, so multi-language header
|
2019-03-15 15:19:27 -07:00
|
|
|
files are easier to write and use.
|
2019-03-22 14:27:18 -07:00
|
|
|
* $ and \ edit descriptors are supported in FORMAT to suppress newline
|
|
|
|
|
output on user prompts.
|
2021-10-21 14:47:55 -07:00
|
|
|
* Tabs in format strings (not `FORMAT` statements) are allowed on output.
|
2019-06-04 15:14:34 -07:00
|
|
|
* REAL and DOUBLE PRECISION variable and bounds in DO loops
|
2019-05-30 13:31:11 -07:00
|
|
|
* Integer literals without explicit kind specifiers that are out of range
|
|
|
|
|
for the default kind of INTEGER are assumed to have the least larger kind
|
|
|
|
|
that can hold them, if one exists.
|
2019-06-03 10:51:51 -07:00
|
|
|
* BOZ literals can be used as INTEGER values in contexts where the type is
|
2022-08-25 18:10:02 +02:00
|
|
|
unambiguous: the right hand sides of assignments and initializations
|
2022-01-11 10:38:26 -08:00
|
|
|
of INTEGER entities, as actual arguments to a few intrinsic functions
|
|
|
|
|
(ACHAR, BTEST, CHAR), and as actual arguments of references to
|
|
|
|
|
procedures with explicit interfaces whose corresponding dummy
|
|
|
|
|
argument has a numeric type to which the BOZ literal may be
|
|
|
|
|
converted. BOZ literals are interpreted as default INTEGER only
|
2021-06-02 17:02:43 -07:00
|
|
|
when they appear as the first items of array constructors with no
|
|
|
|
|
explicit type. Otherwise, they generally cannot be used if the type would
|
[flang][NFC] document BOZ error in DIM, MOD, MODULO, and SIGN (#87779)
It is highly ambiguous to what type BOZ should be resolved in DIM, MOD,
MODULO, and SIGN intrinsic arguments. Some other compilers accept them,
but none agree. See table below.
List them explicitly as non supported extensions (semantics already
reject them, this is an NFC).
Table listing the resolved types of the intrinsic results when there is
a BOZ argument:
| | gfortran | nvfortran | ifort | nagfor | xlf |
| ------------------- | -------- | --------- | ----- | ------ | ------ |
| DIM(INT4, BOZ) | INT16 | INT4 | INT8 | crash | INT4 |
| DIM(BOZ, REAL4) | error | INT8 | error | error | REAL4 |
| DIM(REAL4, BOZ) | error | REAL4 | error | error | REAL4 |
| DIM(BOZ, INT4) | INT16 | INT8 | INT8 | INT8 | INT4 |
| DIM(BOZ, BOZ) | INT16 | INT8 | INT8 | INT8 | REAL4 |
| MOD(INT4, BOZ) | INT16 | INT4 | INT8 | crash | INT4 |
| MOD(BOZ, REAL4) | error | INT8 | error | error | REAL4 |
| MOD(REAL4, BOZ) | error | REAL4 | error | error | REAL4 |
| MOD(BOZ, INT4) | INT16 | INT8 | INT8 | INT8 | INT4 |
| MOD(BOZ, BOZ) | INT16 | INT8 | INT8 | INT8 | INT4 |
| MODULO(INT4, BOZ) | INT16 | INT4 | INT8 | crash | INT4 |
| MODULO(BOZ, REAL4) | error | INT8 | error | error | REAL4 |
| MODULO(REAL4, BOZ) | error | REAL4 | error | error | REAL4 |
| MODULO(BOZ, INT4) | INT16 | INT8 | INT8 | INT8 | INT4 |
| MODULO(BOZ, BOZ) | INT16 | INT8 | INT8 | INT8 | INT8 |
| SIGN(INT4, BOZ) | error | INT4 | INT8 | INT4 | INT4 |
| SIGN(BOZ, REAL4) | error | INT8 | error | error | REAL4 |
| SIGN(REAL4, BOZ) | error | REAL4 | error | error | REAL4 |
| SIGN(BOZ, INT4) | error | INT8 | INT8 | INT8 | INT4 |
| SIGN(BOZ, BOZ) | INT16 | INT8 | INT8 | INT8 | REAL4 |
2024-04-08 10:19:34 +02:00
|
|
|
not be known (e.g., `IAND(X'1',X'2')`, or as arguments of `DIM`, `MOD`,
|
|
|
|
|
`MODULO`, and `SIGN`. Note that while other compilers may accept such usages,
|
|
|
|
|
the type resolution of such BOZ literals usages is highly non portable).
|
2019-07-17 14:29:11 -07:00
|
|
|
* BOZ literals can also be used as REAL values in some contexts where the
|
|
|
|
|
type is unambiguous, such as initializations of REAL parameters.
|
2022-02-09 16:32:58 -08:00
|
|
|
* EQUIVALENCE of numeric and character sequences (a ubiquitous extension),
|
|
|
|
|
as well as of sequences of non-default kinds of numeric types
|
|
|
|
|
with each other.
|
2019-06-21 14:07:39 -07:00
|
|
|
* Values for whole anonymous parent components in structure constructors
|
|
|
|
|
(e.g., `EXTENDEDTYPE(PARENTTYPE(1,2,3))` rather than `EXTENDEDTYPE(1,2,3)`
|
|
|
|
|
or `EXTENDEDTYPE(PARENTTYPE=PARENTTYPE(1,2,3))`).
|
2019-07-17 12:51:52 -07:00
|
|
|
* Some intrinsic functions are specified in the standard as requiring the
|
|
|
|
|
same type and kind for their arguments (viz., ATAN with two arguments,
|
2023-10-31 11:03:02 -07:00
|
|
|
ATAN2, DIM, HYPOT, IAND, IEOR, IOR, MAX, MIN, MOD, and MODULO);
|
2019-07-17 12:51:52 -07:00
|
|
|
we allow distinct types to be used, promoting
|
|
|
|
|
the arguments as if they were operands to an intrinsic `+` operator,
|
|
|
|
|
and defining the result type accordingly.
|
2019-09-17 01:54:51 -07:00
|
|
|
* DOUBLE COMPLEX intrinsics DREAL, DCMPLX, DCONJG, and DIMAG.
|
2021-07-28 16:14:17 -07:00
|
|
|
* The DFLOAT intrinsic function.
|
2019-08-26 14:58:10 -07:00
|
|
|
* INT_PTR_KIND intrinsic returns the kind of c_intptr_t.
|
2019-09-16 09:34:10 -07:00
|
|
|
* Restricted specific conversion intrinsics FLOAT, SNGL, IDINT, IFIX, DREAL,
|
|
|
|
|
and DCMPLX accept arguments of any kind instead of only the default kind or
|
|
|
|
|
double precision kind. Their result kinds remain as specified.
|
|
|
|
|
* Specific intrinsics AMAX0, AMAX1, AMIN0, AMIN1, DMAX1, DMIN1, MAX0, MAX1,
|
2019-09-17 01:54:51 -07:00
|
|
|
MIN0, and MIN1 accept more argument types than specified. They are replaced by
|
2019-09-16 09:34:10 -07:00
|
|
|
the related generics followed by conversions to the specified result types.
|
2019-10-16 15:36:54 -07:00
|
|
|
* When a scalar CHARACTER actual argument of the same kind is known to
|
|
|
|
|
have a length shorter than the associated dummy argument, it is extended
|
|
|
|
|
on the right with blanks, similar to assignment.
|
2019-10-29 12:46:25 -07:00
|
|
|
* When a dummy argument is `POINTER` or `ALLOCATABLE` and is `INTENT(IN)`, we
|
|
|
|
|
relax enforcement of some requirements on actual arguments that must otherwise
|
|
|
|
|
hold true for definable arguments.
|
2024-05-23 16:45:04 -07:00
|
|
|
* We allow a limited polymorphic `POINTER` or `ALLOCATABLE` actual argument
|
|
|
|
|
to be associated with a compatible monomorphic dummy argument, as
|
|
|
|
|
our implementation, like others, supports a reallocation that would
|
|
|
|
|
change the dynamic type
|
2019-12-06 09:37:07 -08:00
|
|
|
* Assignment of `LOGICAL` to `INTEGER` and vice versa (but not other types) is
|
2023-03-27 19:28:36 -07:00
|
|
|
allowed. The values are normalized to canonical `.TRUE.`/`.FALSE.`.
|
|
|
|
|
The values are also normalized for assignments of `LOGICAL(KIND=K1)` to
|
|
|
|
|
`LOGICAL(KIND=K2)`, when `K1 != K2`.
|
2022-01-04 09:25:40 -08:00
|
|
|
* Static initialization of `LOGICAL` with `INTEGER` is allowed in `DATA` statements
|
|
|
|
|
and object initializers.
|
|
|
|
|
The results are *not* normalized to canonical `.TRUE.`/`.FALSE.`.
|
|
|
|
|
Static initialization of `INTEGER` with `LOGICAL` is also permitted.
|
2019-12-06 09:37:07 -08:00
|
|
|
* An effectively empty source file (no program unit) is accepted and
|
|
|
|
|
produces an empty relocatable output file.
|
2020-01-13 15:13:09 -08:00
|
|
|
* A `RETURN` statement may appear in a main program.
|
2020-06-19 09:16:21 -07:00
|
|
|
* DATA statement initialization is allowed for procedure pointers outside
|
|
|
|
|
structure constructors.
|
2020-12-15 11:06:44 -08:00
|
|
|
* Nonstandard intrinsic functions: ISNAN, SIZEOF
|
2025-05-28 14:01:28 -07:00
|
|
|
* A forward reference to an INTEGER dummy argument is permitted to appear
|
|
|
|
|
in a specification expression, such as an array bound, in a scope with
|
|
|
|
|
IMPLICIT NONE(TYPE).
|
|
|
|
|
* A forward reference to a default INTEGER scalar
|
2023-03-03 11:43:55 -08:00
|
|
|
`COMMON` block variable is permitted to appear in a specification
|
|
|
|
|
expression, such as an array bound, in a scope with IMPLICIT NONE(TYPE)
|
|
|
|
|
if the name of the variable would have caused it to be implicitly typed
|
2021-02-18 11:55:31 -08:00
|
|
|
as default INTEGER if IMPLICIT NONE(TYPE) were absent.
|
2021-05-12 12:03:21 -07:00
|
|
|
* OPEN(ACCESS='APPEND') is interpreted as OPEN(POSITION='APPEND')
|
|
|
|
|
to ease porting from Sun Fortran.
|
2021-09-23 16:36:04 -07:00
|
|
|
* Intrinsic subroutines EXIT([status]) and ABORT()
|
2021-10-12 10:17:02 -07:00
|
|
|
* The definition of simple contiguity in 9.5.4 applies only to arrays;
|
|
|
|
|
we also treat scalars as being trivially contiguous, so that they
|
|
|
|
|
can be used in contexts like data targets in pointer assignments
|
|
|
|
|
with bounds remapping.
|
2023-10-31 16:04:35 -07:00
|
|
|
* The `CONTIGUOUS` attribute can be redundantly applied to simply
|
|
|
|
|
contiguous objects, including scalars, with a portability warning.
|
2021-10-18 10:44:39 -07:00
|
|
|
* We support some combinations of specific procedures in generic
|
|
|
|
|
interfaces that a strict reading of the standard would preclude
|
|
|
|
|
when their calls must nonetheless be distinguishable.
|
|
|
|
|
Specifically, `ALLOCATABLE` dummy arguments are distinguishing
|
|
|
|
|
if an actual argument acceptable to one could not be passed to
|
|
|
|
|
the other & vice versa because exactly one is polymorphic or
|
|
|
|
|
exactly one is unlimited polymorphic).
|
2021-11-18 09:34:43 -08:00
|
|
|
* External unit 0 is predefined and connected to the standard error output,
|
|
|
|
|
and defined as `ERROR_UNIT` in the intrinsic `ISO_FORTRAN_ENV` module.
|
2021-12-30 08:14:59 -08:00
|
|
|
* Objects in blank COMMON may be initialized.
|
[flang] Handle common block with different sizes in same file
Semantics is not preventing a named common block to appear with
different size in a same file (named common block should always have
the same storage size (see Fortran 2018 8.10.2.5), but it is a common
extension to accept different sizes).
Lowering was not coping with this well, since it just use the first
common block appearance, starting with BLOCK DATAs to define common
blocks (this also was an issue with the blank common block, which can
legally appear with different size in different scoping units).
Semantics is also not preventing named common from being initialized
outside of a BLOCK DATA, and lowering was dealing badly with this,
since it only gave an initial value to common blocks Globals if the
first common block appearance, starting with BLOCK DATAs had an initial
value.
Semantics is also allowing blank common to be initialized, while
lowering was assuming this would never happen, and was never creating
an initial value for it.
Lastly, semantics was not complaining if a COMMON block was initialized
in several scoping unit in a same file, while lowering can only generate
one of these initial value.
To fix this, add a structure to keep track of COMMON block properties
(biggest size, and initial value if any) at the Program level. Once the
size of a common block appearance is know, the common block appearance
is checked against this information. It allows semantics to emit an error
in case of multiple initialization in different scopes of a same common
block, and to warn in case named common blocks appears with different
sizes. Lastly, this allows lowering to use the Program level info about
common blocks to emit the right GlobalOp for a Common Block, regardless
of the COMMON Block appearances order: It emits a GlobalOp with the
biggest size, whose lowest bytes are initialized with the initial value
if any is given in a scope where the common block appears.
Lowering is updated to go emit the common blocks before anything else so
that the related GlobalOps are available when lowering the scopes where
common block appear. It is also updated to not assume that blank common
are never initialized.
Differential Revision: https://reviews.llvm.org/D124622
2022-04-29 14:52:27 +02:00
|
|
|
* Initialization of COMMON blocks outside of BLOCK DATA subprograms.
|
2021-12-30 14:24:33 -08:00
|
|
|
* Multiple specifications of the SAVE attribute on the same object
|
|
|
|
|
are allowed, with a warning.
|
2022-01-05 09:54:16 -08:00
|
|
|
* Specific intrinsic functions BABS, IIABS, JIABS, KIABS, ZABS, and CDABS.
|
2022-01-04 17:09:33 -08:00
|
|
|
* A `POINTER` component's type need not be a sequence type when
|
|
|
|
|
the component appears in a derived type with `SEQUENCE`.
|
|
|
|
|
(This case should probably be an exception to constraint C740 in
|
|
|
|
|
the standard.)
|
2022-01-06 17:03:40 -08:00
|
|
|
* Format expressions that have type but are not character and not
|
|
|
|
|
integer scalars are accepted so long as they are simply contiguous.
|
|
|
|
|
This legacy extension supports pre-Fortran'77 usage in which
|
|
|
|
|
variables initialized in DATA statements with Hollerith literals
|
|
|
|
|
as modifiable formats.
|
2022-01-12 17:34:52 -08:00
|
|
|
* At runtime, `NAMELIST` input will skip over `NAMELIST` groups
|
|
|
|
|
with other names, and will treat text before and between groups
|
|
|
|
|
as if they were comment lines, even if not begun with `!`.
|
2022-02-16 16:41:53 -08:00
|
|
|
* Commas are required in FORMAT statements and character variables
|
|
|
|
|
only when they prevent ambiguity.
|
2022-03-11 11:17:01 -08:00
|
|
|
* Legacy names `AND`, `OR`, and `XOR` are accepted as aliases for
|
|
|
|
|
the standard intrinsic functions `IAND`, `IOR`, and `IEOR`
|
|
|
|
|
respectively.
|
2022-06-08 15:52:46 -07:00
|
|
|
* A digit count of d=0 is accepted in Ew.0, Dw.0, and Gw.0 output
|
|
|
|
|
editing if no nonzero scale factor (kP) is in effect.
|
2022-08-12 12:28:44 -07:00
|
|
|
* The name `IMAG` is accepted as an alias for the generic intrinsic
|
|
|
|
|
function `AIMAG`.
|
|
|
|
|
* The legacy extension intrinsic functions `IZEXT` and `JZEXT`
|
|
|
|
|
are supported; `ZEXT` has different behavior with various older
|
|
|
|
|
compilers, so it is not supported.
|
2022-11-04 16:39:52 -07:00
|
|
|
* f18 doesn't impose a limit on the number of continuation lines
|
|
|
|
|
allowed for a single statement.
|
2022-11-07 15:51:03 -08:00
|
|
|
* When a type-bound procedure declaration statement has neither interface
|
|
|
|
|
nor attributes, the "::" before the bindings is optional, even
|
|
|
|
|
if a binding has renaming with "=> proc".
|
|
|
|
|
The colons are not necessary for an unambiguous parse, C768
|
|
|
|
|
notwithstanding.
|
2022-12-01 10:13:57 -08:00
|
|
|
* A type-bound procedure binding can be passed as an actual
|
|
|
|
|
argument corresponding to a dummy procedure and can be used as
|
|
|
|
|
the target of a procedure pointer assignment statement.
|
2022-12-10 10:59:52 -08:00
|
|
|
* An explicit `INTERFACE` can declare the interface of a
|
|
|
|
|
procedure pointer even if it is not a dummy argument.
|
2022-12-17 07:33:04 -08:00
|
|
|
* A `NOPASS` type-bound procedure binding is required by C1529
|
|
|
|
|
to apply only to a scalar data-ref, but most compilers don't
|
|
|
|
|
enforce it and the constraint is not necessary for a correct
|
|
|
|
|
implementation.
|
2023-02-05 17:25:28 -08:00
|
|
|
* A label may follow a semicolon in fixed form source.
|
2024-04-09 15:05:12 -04:00
|
|
|
* A logical dummy argument to a `BIND(C)` procedure, or a logical
|
|
|
|
|
component to a `BIND(C)` derived type does not have to have
|
|
|
|
|
`KIND=C_BOOL` since it can be converted to/from `_Bool` without
|
|
|
|
|
loss of information.
|
2023-03-17 14:13:39 -07:00
|
|
|
* The character length of the `SOURCE=` or `MOLD=` in `ALLOCATE`
|
|
|
|
|
may be distinct from the constant character length, if any,
|
|
|
|
|
of an allocated object.
|
2023-03-29 08:56:31 -07:00
|
|
|
* When a name is brought into a scope by multiple ways,
|
|
|
|
|
such as USE-association as well as an `IMPORT` from its host,
|
|
|
|
|
it's an error only if the resolution is ambiguous.
|
2023-07-11 10:05:22 -07:00
|
|
|
* An entity may appear in a `DATA` statement before its explicit
|
|
|
|
|
type declaration under `IMPLICIT NONE(TYPE)`.
|
2023-11-13 15:50:49 -08:00
|
|
|
* `INCLUDE` lines can start in any column, can be preceded in
|
2023-07-17 09:42:12 -07:00
|
|
|
fixed form source by a '0' in column 6, can contain spaces
|
|
|
|
|
between the letters of the word INCLUDE, and can have a
|
|
|
|
|
numeric character literal kind prefix on the file name.
|
2024-01-29 05:16:27 -08:00
|
|
|
* Intrinsic procedures SIND, COSD, TAND and ATAND. Constant folding
|
|
|
|
|
is currently not supported for these procedures but this is planned.
|
2023-07-20 10:39:04 -07:00
|
|
|
* When a pair of quotation marks in a character literal are split
|
|
|
|
|
by a line continuation in free form, the second quotation mark
|
|
|
|
|
may appear at the beginning of the continuation line without an
|
|
|
|
|
ampersand, althought one is required by the standard.
|
2023-08-02 12:37:21 -07:00
|
|
|
* Unrestricted `INTRINSIC` functions are accepted for use in
|
|
|
|
|
`PROCEDURE` statements in generic interfaces, as in some other
|
|
|
|
|
compilers.
|
2023-09-18 12:37:46 -07:00
|
|
|
* A `NULL()` pointer is treated as an unallocated allocatable
|
|
|
|
|
when associated with an `INTENT(IN)` allocatable dummy argument.
|
2023-11-13 14:20:43 -08:00
|
|
|
* `READ(..., SIZE=n)` is accepted with `NML=` and `FMT=*` with
|
|
|
|
|
a portability warning.
|
|
|
|
|
The Fortran standard doesn't allow `SIZE=` with formatted input
|
|
|
|
|
modes that might require look-ahead, perhaps to ease implementations.
|
2023-11-13 15:50:49 -08:00
|
|
|
* When a file included via an `INCLUDE` line or `#include` directive
|
|
|
|
|
has a continuation marker at the end of its last line in free form,
|
|
|
|
|
Fortran line continuation works.
|
2024-01-02 08:42:10 -08:00
|
|
|
* A `NAMELIST` input group may omit its trailing `/` character if
|
|
|
|
|
it is followed by another `NAMELIST` input group.
|
|
|
|
|
* A `NAMELIST` input group may begin with either `&` or `$`.
|
2024-01-15 09:47:52 -08:00
|
|
|
* A comma in a fixed-width numeric input field terminates the
|
|
|
|
|
field rather than signaling an invalid character error.
|
2024-04-08 11:56:36 -07:00
|
|
|
* Arguments to the intrinsic functions `MAX` and `MIN` are converted
|
|
|
|
|
when necessary to the type of the result.
|
|
|
|
|
An `OPTIONAL`, `POINTER`, or `ALLOCATABLE` argument after
|
|
|
|
|
the first two cannot be converted, as it may not be present.
|
2024-05-09 11:04:50 -07:00
|
|
|
* A derived type that meets (most of) the requirements of an interoperable
|
|
|
|
|
derived type can be used as such where an interoperable type is
|
|
|
|
|
required, with warnings, even if it lacks the BIND(C) attribute.
|
[flang] Adjust "doubled operator" expression extension (#93353)
Most Fortran compilers accept "doubled operators" as a language
extension. This is the use of a unary '+' or '-' operator that is not
the first unparenthesized operator in an expression, as in 'x*-y'.
This compiler has implemented this extension, but in a way that's
different from other compilers' behavior. I interpreted the unary
'+'/'-' as a unary operator in the sense of C/C++, giving it a higher
priority than any binary (dyadic) operator.
All other compilers with this extension, however, give a unary '+'/'-' a
lower precedence than exponentiation ('**'), a binary operator that
C/C++ lacks. And this interpretation makes more sense for Fortran,
anyway, where the standard conforming '-x**y' must mean '-(x**y)'
already.
This patch makes 'x*-y**z' parse as 'x*-(y**z)', not 'x*(-y)**z)', and
adds a test to ensure that it does.
2024-06-03 11:58:18 -07:00
|
|
|
* A "mult-operand" in an expression can be preceded by a unary
|
|
|
|
|
`+` or `-` operator.
|
2024-06-11 16:56:30 -07:00
|
|
|
* `BIND(C, NAME="...", CDEFINED)` signifies that the storage for an
|
|
|
|
|
interoperable variable will be allocated outside of Fortran,
|
|
|
|
|
probably by a C or C++ external definition.
|
2024-08-08 11:06:32 -07:00
|
|
|
* An automatic data object may be declared in the specification part
|
|
|
|
|
of the main program.
|
2024-09-10 14:13:09 -07:00
|
|
|
* A local data object may appear in a specification expression, even
|
|
|
|
|
when it is not a dummy argument or in COMMON, so long as it is
|
|
|
|
|
has the SAVE attribute and was initialized.
|
2024-10-15 14:22:22 -07:00
|
|
|
* `PRINT namelistname` is accepted and interpreted as
|
|
|
|
|
`WRITE(*,NML=namelistname)`, a near-universal extension.
|
2024-12-02 12:25:47 -08:00
|
|
|
* A character length specifier in a component or entity declaration
|
|
|
|
|
is accepted before an array specification (`ch*3(2)`) as well
|
|
|
|
|
as afterwards.
|
2025-01-08 13:15:51 -08:00
|
|
|
* A zero field width is allowed for logical formatted output (`L0`).
|
2025-01-31 10:51:16 -08:00
|
|
|
* `OPEN(..., FORM='BINARY')` is accepted as a legacy synonym for
|
|
|
|
|
the standard `OPEN(..., FORM='UNFORMATTED', ACCESS='STREAM')`.
|
2025-05-28 13:58:22 -07:00
|
|
|
* A character string edit descriptor is allowed in an input format
|
|
|
|
|
with an optional compilation-time warning. When executed, it
|
|
|
|
|
is treated as an 'nX' positioning control descriptor that skips
|
|
|
|
|
over the same number of characters, without comparison.
|
2018-07-17 16:58:21 -07:00
|
|
|
|
2020-09-11 14:17:19 +01:00
|
|
|
### Extensions supported when enabled by options
|
|
|
|
|
|
2018-07-17 16:58:21 -07:00
|
|
|
* C-style backslash escape sequences in quoted CHARACTER literals
|
2024-01-15 09:35:17 -08:00
|
|
|
(but not Hollerith) [-fbackslash], including Unicode escapes
|
|
|
|
|
with `\U`.
|
2018-07-17 16:58:21 -07:00
|
|
|
* Logical abbreviations `.T.`, `.F.`, `.N.`, `.A.`, `.O.`, and `.X.`
|
|
|
|
|
[-flogical-abbreviations]
|
|
|
|
|
* `.XOR.` as a synonym for `.NEQV.` [-fxor-operator]
|
2020-01-09 09:39:09 -08:00
|
|
|
* The default `INTEGER` type is required by the standard to occupy
|
|
|
|
|
the same amount of storage as the default `REAL` type. Default
|
|
|
|
|
`REAL` is of course 32-bit IEEE-754 floating-point today. This legacy
|
|
|
|
|
rule imposes an artificially small constraint in some cases
|
|
|
|
|
where Fortran mandates that something have the default `INTEGER`
|
|
|
|
|
type: specifically, the results of references to the intrinsic functions
|
2020-12-15 11:06:44 -08:00
|
|
|
`SIZE`, `STORAGE_SIZE`,`LBOUND`, `UBOUND`, `SHAPE`, and the location reductions
|
2020-01-09 09:39:09 -08:00
|
|
|
`FINDLOC`, `MAXLOC`, and `MINLOC` in the absence of an explicit
|
|
|
|
|
`KIND=` actual argument. We return `INTEGER(KIND=8)` by default in
|
|
|
|
|
these cases when the `-flarge-sizes` option is enabled.
|
2020-12-15 11:06:44 -08:00
|
|
|
`SIZEOF` and `C_SIZEOF` always return `INTEGER(KIND=8)`.
|
2020-08-06 06:47:59 -07:00
|
|
|
* Treat each specification-part like is has `IMPLICIT NONE`
|
|
|
|
|
[-fimplicit-none-type-always]
|
|
|
|
|
* Ignore occurrences of `IMPLICIT NONE` and `IMPLICIT NONE(TYPE)`
|
|
|
|
|
[-fimplicit-none-type-never]
|
2021-01-29 13:34:22 -08:00
|
|
|
* Old-style `PARAMETER pi=3.14` statement without parentheses
|
|
|
|
|
[-falternative-parameter-statement]
|
2024-12-18 07:02:37 -08:00
|
|
|
* `UNSIGNED` type (-funsigned)
|
2018-03-20 10:59:07 -07:00
|
|
|
|
2020-09-11 14:17:19 +01:00
|
|
|
### Extensions and legacy features deliberately not supported
|
|
|
|
|
|
2018-03-20 10:59:07 -07:00
|
|
|
* `.LG.` as synonym for `.NE.`
|
|
|
|
|
* `REDIMENSION`
|
|
|
|
|
* Allocatable `COMMON`
|
|
|
|
|
* Expressions in formats
|
|
|
|
|
* `ACCEPT` as synonym for `READ *`
|
2018-03-23 15:14:52 -07:00
|
|
|
* `TYPE` as synonym for `PRINT`
|
2018-03-20 10:59:07 -07:00
|
|
|
* `ARRAY` as synonym for `DIMENSION`
|
|
|
|
|
* `VIRTUAL` as synonym for `DIMENSION`
|
|
|
|
|
* `ENCODE` and `DECODE` as synonyms for internal I/O
|
|
|
|
|
* `IMPLICIT AUTOMATIC`, `IMPLICIT STATIC`
|
|
|
|
|
* Default exponent of zero, e.g. `3.14159E`
|
|
|
|
|
* Characters in defined operators that are neither letters nor digits
|
|
|
|
|
* `B` suffix on unquoted octal constants
|
2018-10-16 14:42:22 -07:00
|
|
|
* `Z` prefix on unquoted hexadecimal constants (dangerous)
|
2019-06-03 10:51:51 -07:00
|
|
|
* `T` and `F` as abbreviations for `.TRUE.` and `.FALSE.` in DATA (PGI/XLF)
|
2019-02-08 10:39:10 -08:00
|
|
|
* Use of host FORMAT labels in internal subprograms (PGI-only feature)
|
2019-05-30 12:08:06 -07:00
|
|
|
* ALLOCATE(TYPE(derived)::...) as variant of correct ALLOCATE(derived::...) (PGI only)
|
2019-06-24 10:25:37 -07:00
|
|
|
* Defining an explicit interface for a subprogram within itself (PGI only)
|
2019-06-04 14:51:56 -07:00
|
|
|
* USE association of a procedure interface within that same procedure's definition
|
2019-06-05 15:40:59 -07:00
|
|
|
* NULL() as a structure constructor expression for an ALLOCATABLE component (PGI).
|
2019-12-05 16:18:39 -08:00
|
|
|
* Conversion of LOGICAL to INTEGER in expressions.
|
2022-06-01 11:05:55 -07:00
|
|
|
* Use of INTEGER data with the intrinsic logical operators `.NOT.`, `.AND.`, `.OR.`,
|
|
|
|
|
and `.XOR.`.
|
2019-06-05 15:40:59 -07:00
|
|
|
* IF (integer expression) THEN ... END IF (PGI/Intel)
|
2022-08-25 18:10:02 +02:00
|
|
|
* Comparison of LOGICAL with ==/.EQ. rather than .EQV. (also .NEQV.) (PGI/Intel)
|
2019-06-05 15:40:59 -07:00
|
|
|
* Procedure pointers in COMMON blocks (PGI/Intel)
|
2019-06-25 13:07:32 -07:00
|
|
|
* Underindexing multi-dimensional arrays (e.g., A(1) rather than A(1,1)) (PGI only)
|
2019-06-28 11:16:37 -07:00
|
|
|
* Legacy PGI `NCHARACTER` type and `NC` Kanji character literals
|
2019-07-09 11:53:11 -07:00
|
|
|
* Using non-integer expressions for array bounds (e.g., REAL A(3.14159)) (PGI/Intel)
|
|
|
|
|
* Mixing INTEGER types as operands to bit intrinsics (e.g., IAND); only two
|
|
|
|
|
compilers support it, and they disagree on sign extension.
|
2019-07-18 13:57:21 -07:00
|
|
|
* Module & program names that conflict with an object inside the unit (PGI only).
|
2019-07-18 15:26:17 -07:00
|
|
|
* When the same name is brought into scope via USE association from
|
|
|
|
|
multiple modules, the name must refer to a generic interface; PGI
|
|
|
|
|
allows a name to be a procedure from one module and a generic interface
|
|
|
|
|
from another.
|
2019-08-02 15:42:54 -07:00
|
|
|
* Type parameter declarations must come first in a derived type definition;
|
|
|
|
|
some compilers allow them to follow `PRIVATE`, or be intermixed with the
|
|
|
|
|
component declarations.
|
2019-09-16 09:34:10 -07:00
|
|
|
* Wrong argument types in calls to specific intrinsics that have different names than the
|
|
|
|
|
related generics. Some accepted exceptions are listed above in the allowed extensions.
|
2019-09-17 01:54:51 -07:00
|
|
|
PGI, Intel, and XLF support this in ways that are not numerically equivalent.
|
2019-09-16 09:34:10 -07:00
|
|
|
PGI converts the arguments while Intel and XLF replace the specific by the related generic.
|
2022-06-12 09:28:57 -07:00
|
|
|
* VMS listing control directives (`%LIST`, `%NOLIST`, `%EJECT`)
|
|
|
|
|
* Continuation lines on `INCLUDE` lines
|
2022-07-18 10:27:05 -07:00
|
|
|
* `NULL()` actual argument corresponding to an `ALLOCATABLE` dummy data object
|
2022-09-21 12:05:20 -07:00
|
|
|
* User (non-intrinsic) `ELEMENTAL` procedures may not be passed as actual
|
|
|
|
|
arguments, in accordance with the standard; some Fortran compilers
|
|
|
|
|
permit such usage.
|
2023-03-15 12:21:04 -07:00
|
|
|
* Constraint C1406, which prohibits the same module name from being used
|
|
|
|
|
in a scope for both an intrinsic and a non-intrinsic module, is implemented
|
|
|
|
|
as a portability warning only, not a hard error.
|
2023-05-17 08:58:35 -04:00
|
|
|
* IBM @PROCESS directive is accepted but ignored.
|
2019-07-10 15:03:02 -07:00
|
|
|
|
2020-09-11 14:17:19 +01:00
|
|
|
## Preprocessing behavior
|
|
|
|
|
|
2019-07-10 15:03:02 -07:00
|
|
|
* The preprocessor is always run, whatever the filename extension may be.
|
|
|
|
|
* We respect Fortran comments in macro actual arguments (like GNU, Intel, NAG;
|
|
|
|
|
unlike PGI and XLF) on the principle that macro calls should be treated
|
|
|
|
|
like function references. Fortran's line continuation methods also work.
|
2025-05-30 14:33:53 +02:00
|
|
|
* We implement the `__COUNTER__` preprocessing extension,
|
|
|
|
|
see [Non-standard Extensions](Preprocessing.md#non-standard-extensions)
|
2021-02-17 10:24:14 -08:00
|
|
|
|
|
|
|
|
## Standard features not silently accepted
|
|
|
|
|
|
|
|
|
|
* Fortran explicitly ignores type declaration statements when they
|
|
|
|
|
attempt to type the name of a generic intrinsic function (8.2 p3).
|
|
|
|
|
One can declare `CHARACTER::COS` and still get a real result
|
|
|
|
|
from `COS(3.14159)`, for example. f18 will complain when a
|
|
|
|
|
generic intrinsic function's inferred result type does not
|
|
|
|
|
match an explicit declaration. This message is a warning.
|
2021-07-19 11:53:20 -07:00
|
|
|
|
|
|
|
|
## Standard features that might as well not be
|
|
|
|
|
|
|
|
|
|
* f18 supports designators with constant expressions, properly
|
|
|
|
|
constrained, as initial data targets for data pointers in
|
|
|
|
|
initializers of variable and component declarations and in
|
|
|
|
|
`DATA` statements; e.g., `REAL, POINTER :: P => T(1:10:2)`.
|
|
|
|
|
This Fortran 2008 feature might as well be viewed like an
|
|
|
|
|
extension; no other compiler that we've tested can handle
|
|
|
|
|
it yet.
|
2022-10-04 11:10:59 -07:00
|
|
|
* According to 11.1.3.3p1, if a selector of an `ASSOCIATE` or
|
|
|
|
|
related construct is defined by a variable, it has the `TARGET`
|
|
|
|
|
attribute if the variable was a `POINTER` or `TARGET`.
|
|
|
|
|
We read this to include the case of the variable being a
|
|
|
|
|
pointer-valued function reference.
|
|
|
|
|
No other Fortran compiler seems to handle this correctly for
|
|
|
|
|
`ASSOCIATE`, though NAG gets it right for `SELECT TYPE`.
|
2022-11-02 15:32:17 -07:00
|
|
|
* The standard doesn't explicitly require that a named constant that
|
|
|
|
|
appears as part of a complex-literal-constant be a scalar, but
|
|
|
|
|
most compilers emit an error when an array appears.
|
|
|
|
|
f18 supports them with a portability warning.
|
2022-11-06 11:37:12 -08:00
|
|
|
* f18 does not enforce a blanket prohibition against generic
|
|
|
|
|
interfaces containing a mixture of functions and subroutines.
|
2024-09-10 14:10:40 -07:00
|
|
|
We allow both to appear, unlike several other Fortran compilers.
|
2022-11-06 11:37:12 -08:00
|
|
|
This is especially desirable when two generics of the same
|
|
|
|
|
name are combined due to USE association and the mixture may
|
|
|
|
|
be inadvertent.
|
2023-11-13 15:50:49 -08:00
|
|
|
* Since Fortran 90, `INCLUDE` lines have been allowed to have
|
2023-07-17 09:42:12 -07:00
|
|
|
a numeric kind parameter prefix on the file name. No other
|
|
|
|
|
Fortran compiler supports them that I can find.
|
2023-09-18 12:11:35 -07:00
|
|
|
* A `SEQUENCE` derived type is required (F'2023 C745) to have
|
|
|
|
|
at least one component. No compiler enforces this constraint;
|
|
|
|
|
this compiler emits a warning.
|
2024-01-15 12:31:52 -08:00
|
|
|
* Many compilers disallow a `VALUE` assumed-length character dummy
|
|
|
|
|
argument, which has been standard since F'2008.
|
|
|
|
|
We accept this usage with an optional portability warning.
|
2024-03-01 14:43:31 -08:00
|
|
|
* The `ASYNCHRONOUS` attribute can be implied by usage in data
|
|
|
|
|
transfer I/O statements. Only one other compiler supports this
|
|
|
|
|
correctly. This compiler does, apart from objects in asynchronous
|
|
|
|
|
NAMELIST I/O, for which an actual asynchronous runtime implementation
|
|
|
|
|
seems unlikely.
|
2021-10-04 12:40:35 -07:00
|
|
|
|
|
|
|
|
## Behavior in cases where the standard is ambiguous or indefinite
|
|
|
|
|
|
|
|
|
|
* When an inner procedure of a subprogram uses the value or an attribute
|
|
|
|
|
of an undeclared name in a specification expression and that name does
|
|
|
|
|
not appear in the host, it is not clear in the standard whether that
|
|
|
|
|
name is an implicitly typed local variable of the inner procedure or a
|
|
|
|
|
host association with an implicitly typed local variable of the host.
|
|
|
|
|
For example:
|
|
|
|
|
```
|
|
|
|
|
module module
|
|
|
|
|
contains
|
|
|
|
|
subroutine host(j)
|
|
|
|
|
! Although "m" never appears in the specification or executable
|
|
|
|
|
! parts of this subroutine, both of its contained subroutines
|
|
|
|
|
! might be accessing it via host association.
|
|
|
|
|
integer, intent(in out) :: j
|
|
|
|
|
call inner1(j)
|
|
|
|
|
call inner2(j)
|
|
|
|
|
contains
|
|
|
|
|
subroutine inner1(n)
|
|
|
|
|
integer(kind(m)), intent(in) :: n
|
|
|
|
|
m = n + 1
|
|
|
|
|
end subroutine
|
|
|
|
|
subroutine inner2(n)
|
|
|
|
|
integer(kind(m)), intent(out) :: n
|
|
|
|
|
n = m + 2
|
|
|
|
|
end subroutine
|
|
|
|
|
end subroutine
|
|
|
|
|
end module
|
|
|
|
|
|
|
|
|
|
program demo
|
|
|
|
|
use module
|
|
|
|
|
integer :: k
|
|
|
|
|
k = 0
|
|
|
|
|
call host(k)
|
|
|
|
|
print *, k, " should be 3"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Other Fortran compilers disagree in their interpretations of this example;
|
|
|
|
|
some seem to treat the references to `m` as if they were host associations
|
|
|
|
|
to an implicitly typed variable (and print `3`), while others seem to
|
2023-05-10 13:26:01 -07:00
|
|
|
treat them as references to implicitly typed local variables, and
|
2021-10-04 12:40:35 -07:00
|
|
|
load uninitialized values.
|
|
|
|
|
|
|
|
|
|
In f18, we chose to emit an error message for this case since the standard
|
|
|
|
|
is unclear, the usage is not portable, and the issue can be easily resolved
|
|
|
|
|
by adding a declaration.
|
|
|
|
|
|
|
|
|
|
* In subclause 7.5.6.2 of Fortran 2018 the standard defines a partial ordering
|
|
|
|
|
of the final subroutine calls for finalizable objects, their non-parent
|
|
|
|
|
components, and then their parent components.
|
|
|
|
|
(The object is finalized, then the non-parent components of each element,
|
|
|
|
|
and then the parent component.)
|
|
|
|
|
Some have argued that the standard permits an implementation
|
|
|
|
|
to finalize the parent component before finalizing an allocatable component in
|
|
|
|
|
the context of deallocation, and the next revision of the language may codify
|
|
|
|
|
this option.
|
|
|
|
|
In the interest of avoiding needless confusion, this compiler implements what
|
|
|
|
|
we believe to be the least surprising order of finalization.
|
|
|
|
|
Specifically: all non-parent components are finalized before
|
|
|
|
|
the parent, allocatable or not;
|
|
|
|
|
all finalization takes place before any deallocation;
|
|
|
|
|
and no object or subobject will be finalized more than once.
|
2021-12-02 16:36:09 -08:00
|
|
|
|
|
|
|
|
* When `RECL=` is set via the `OPEN` statement for a sequential formatted input
|
|
|
|
|
file, it functions as an effective maximum record length.
|
|
|
|
|
Longer records, if any, will appear as if they had been truncated to
|
|
|
|
|
the value of `RECL=`.
|
|
|
|
|
(Other compilers ignore `RECL=`, signal an error, or apply effective truncation
|
|
|
|
|
to some forms of input in this situation.)
|
|
|
|
|
For sequential formatted output, RECL= serves as a limit on record lengths
|
|
|
|
|
that raises an error when it is exceeded.
|
2022-09-21 11:57:12 -07:00
|
|
|
|
|
|
|
|
* When a `DATA` statement in a `BLOCK` construct could be construed as
|
|
|
|
|
either initializing a host-associated object or declaring a new local
|
|
|
|
|
initialized object, f18 interprets the standard's classification of
|
|
|
|
|
a `DATA` statement as being a "declaration" rather than a "specification"
|
|
|
|
|
construct, and notes that the `BLOCK` construct is defined as localizing
|
|
|
|
|
names that have specifications in the `BLOCK` construct.
|
|
|
|
|
So this example will elicit an error about multiple initialization:
|
|
|
|
|
```
|
|
|
|
|
subroutine subr
|
|
|
|
|
integer n = 1
|
|
|
|
|
block
|
|
|
|
|
data n/2/
|
|
|
|
|
end block
|
|
|
|
|
end subroutine
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Other Fortran compilers disagree with each other in their interpretations
|
|
|
|
|
of this example.
|
|
|
|
|
The precedent among the most commonly used compilers
|
|
|
|
|
agrees with f18's interpretation: a `DATA` statement without any other
|
|
|
|
|
specification of the name refers to the host-associated object.
|
2022-10-04 10:24:29 -07:00
|
|
|
|
|
|
|
|
* Many Fortran compilers allow a non-generic procedure to be `USE`-associated
|
|
|
|
|
into a scope that also contains a generic interface of the same name
|
|
|
|
|
but does not have the `USE`-associated non-generic procedure as a
|
|
|
|
|
specific procedure.
|
|
|
|
|
```
|
|
|
|
|
module m1
|
|
|
|
|
contains
|
|
|
|
|
subroutine foo(n)
|
|
|
|
|
integer, intent(in) :: n
|
|
|
|
|
end subroutine
|
|
|
|
|
end module
|
|
|
|
|
|
|
|
|
|
module m2
|
|
|
|
|
use m1, only: foo
|
|
|
|
|
interface foo
|
|
|
|
|
module procedure noargs
|
|
|
|
|
end interface
|
|
|
|
|
contains
|
|
|
|
|
subroutine noargs
|
|
|
|
|
end subroutine
|
|
|
|
|
end module
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
This case elicits a warning from f18, as it should not be treated
|
|
|
|
|
any differently than the same case with the non-generic procedure of
|
|
|
|
|
the same name being defined in the same scope rather than being
|
|
|
|
|
`USE`-associated into it, which is explicitly non-conforming in the
|
|
|
|
|
standard and not allowed by most other compilers.
|
|
|
|
|
If the `USE`-associated entity of the same name is not a procedure,
|
|
|
|
|
most compilers disallow it as well.
|
2022-10-24 11:22:22 -07:00
|
|
|
|
|
|
|
|
* Fortran 2018 19.3.4p1: "A component name has the scope of its derived-type
|
|
|
|
|
definition. Outside the type definition, it may also appear ..." which
|
|
|
|
|
seems to imply that within its derived-type definition, a component
|
|
|
|
|
name is in its scope, and at least shadows any entity of the same name
|
|
|
|
|
in the enclosing scope and might be read, thanks to the "also", to mean
|
|
|
|
|
that a "bare" reference to the name could be used in a specification inquiry.
|
|
|
|
|
However, most other compilers do not allow a component to shadow exterior
|
|
|
|
|
symbols, much less appear in specification inquiries, and there are
|
|
|
|
|
application codes that expect exterior symbols whose names match
|
|
|
|
|
components to be visible in a derived-type definition's default initialization
|
|
|
|
|
expressions, and so f18 follows that precedent.
|
2022-11-14 14:38:03 -08:00
|
|
|
|
|
|
|
|
* 19.3.1p1 "Within its scope, a local identifier of an entity of class (1)
|
|
|
|
|
or class (4) shall not be the same as a global identifier used in that scope..."
|
|
|
|
|
is read so as to allow the name of a module, submodule, main program,
|
|
|
|
|
or `BLOCK DATA` subprogram to also be the name of an local entity in its
|
|
|
|
|
scope, with a portability warning, since that global name is not actually
|
|
|
|
|
capable of being "used" in its scope.
|
2022-12-16 11:44:51 -08:00
|
|
|
|
2023-01-11 14:31:49 -08:00
|
|
|
* In the definition of the `ASSOCIATED` intrinsic function (16.9.16), its optional
|
|
|
|
|
second argument `TARGET=` is required to be "allowable as the data-target or
|
|
|
|
|
proc-target in a pointer assignment statement (10.2.2) in which POINTER is
|
|
|
|
|
data-pointer-object or proc-pointer-object." Some Fortran compilers
|
|
|
|
|
interpret this to require that the first argument (`POINTER=`) be a valid
|
|
|
|
|
left-hand side for a pointer assignment statement -- in particular, it
|
|
|
|
|
cannot be `NULL()`, but also it is required to be modifiable.
|
|
|
|
|
As there is no good reason to disallow (say) an `INTENT(IN)` pointer here,
|
|
|
|
|
or even `NULL()` as a well-defined case that is always `.FALSE.`,
|
|
|
|
|
this compiler doesn't require the `POINTER=` argument to be a valid
|
|
|
|
|
left-hand side for a pointer assignment statement, and we emit a
|
|
|
|
|
portability warning when it is not.
|
|
|
|
|
|
2023-02-04 17:55:45 -08:00
|
|
|
* F18 allows a `USE` statement to reference a module that is defined later
|
|
|
|
|
in the same compilation unit, so long as mutual dependencies do not form
|
|
|
|
|
a cycle.
|
|
|
|
|
This feature forestalls any risk of such a `USE` statement reading an
|
|
|
|
|
obsolete module file from a previous compilation and then overwriting
|
|
|
|
|
that file later.
|
|
|
|
|
|
2023-03-06 14:29:53 -08:00
|
|
|
* F18 allows `OPTIONAL` dummy arguments to interoperable procedures
|
|
|
|
|
unless they are `VALUE` (C865).
|
|
|
|
|
|
2023-06-29 13:03:14 -07:00
|
|
|
* F18 processes the `NAMELIST` group declarations in a scope after it
|
|
|
|
|
has resolved all of the names in that scope. This means that names
|
|
|
|
|
that appear before their local declarations do not resolve to host
|
|
|
|
|
associated objects and do not elicit errors about improper redeclarations
|
|
|
|
|
of implicitly typed entities.
|
|
|
|
|
|
2023-10-16 15:40:13 -07:00
|
|
|
* Standard Fortran allows forward references to derived types, which
|
|
|
|
|
can lead to ambiguity when combined with host association.
|
|
|
|
|
Some Fortran compilers resolve the type name to the host type,
|
|
|
|
|
others to the forward-referenced local type; this compiler diagnoses
|
|
|
|
|
an error.
|
|
|
|
|
```
|
|
|
|
|
module m
|
|
|
|
|
type ambiguous; integer n; end type
|
|
|
|
|
contains
|
|
|
|
|
subroutine s
|
|
|
|
|
type(ambiguous), pointer :: ptr
|
|
|
|
|
type ambiguous; real a; end type
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
```
|
2023-06-29 13:03:14 -07:00
|
|
|
|
2023-12-26 16:03:03 -08:00
|
|
|
* When an intrinsic procedure appears in the specification part of a module
|
|
|
|
|
only in function references, but not an explicit `INTRINSIC` statement,
|
|
|
|
|
its name is not brought into other scopes by a `USE` statement.
|
|
|
|
|
|
2024-01-15 10:39:22 -08:00
|
|
|
* The subclause on rounding in formatted I/O (13.7.2.3.8 in F'2023)
|
|
|
|
|
only discusses rounding for decimal-to/from-binary conversions,
|
|
|
|
|
omitting any mention of rounding for hexadecimal conversions.
|
|
|
|
|
As other compilers do apply rounding, so does this one.
|
2024-01-02 09:32:54 -08:00
|
|
|
|
2024-01-15 10:29:26 -08:00
|
|
|
* For real `MAXVAL`, `MINVAL`, `MAXLOC`, and `MINLOC`, NaN values are
|
|
|
|
|
essentially ignored unless there are some unmasked array entries and
|
|
|
|
|
*all* of them are NaNs.
|
|
|
|
|
|
2024-03-01 16:59:36 -08:00
|
|
|
* When `INDEX` is used as an unrestricted specific intrinsic function
|
|
|
|
|
in the context of an actual procedure, as the explicit interface in
|
|
|
|
|
a `PROCEDURE` declaration statement, or as the target of a procedure
|
|
|
|
|
pointer assignment, its interface has exactly two dummy arguments
|
|
|
|
|
(`STRING=` and `SUBSTRING=`), and includes neither `BACK=` nor
|
|
|
|
|
`KIND=`.
|
|
|
|
|
This is how `INDEX` as an unrestricted specific intrinsic function was
|
|
|
|
|
documented in FORTRAN '77 and Fortran '90; later revisions of the
|
|
|
|
|
standard deleted the argument information from the section on
|
|
|
|
|
unrestricted specific intrinsic functions.
|
|
|
|
|
At least one other compiler (XLF) seems to expect that the interface for
|
|
|
|
|
`INDEX` include an optional `BACK=` argument, but it doesn't actually
|
|
|
|
|
work.
|
|
|
|
|
|
2024-03-05 09:25:17 +01:00
|
|
|
* Allocatable components of array and structure constructors are deallocated
|
|
|
|
|
after use without calling final subroutines.
|
|
|
|
|
The standard does not specify when and how deallocation of array and structure
|
|
|
|
|
constructors allocatable components should happen. All compilers free the
|
|
|
|
|
memory after use, but the behavior when the allocatable component is a derived
|
|
|
|
|
type with finalization differ, especially when dealing with nested array and
|
|
|
|
|
structure constructors expressions. Some compilers call final routine for the
|
|
|
|
|
allocatable components of each constructor sub-expressions, some call it only
|
|
|
|
|
for the allocatable component of the top level constructor, and some only
|
|
|
|
|
deallocate the memory. Deallocating only the memory offers the most
|
|
|
|
|
flexibility when lowering such expressions, and it is not clear finalization
|
|
|
|
|
is desirable in such context (Fortran interop 1.6.2 in F2018 standards require
|
|
|
|
|
array and structure constructors not to be finalized, so it also makes sense
|
|
|
|
|
not to finalize their allocatable components when releasing their storage).
|
|
|
|
|
|
2024-05-09 10:17:15 -07:00
|
|
|
* F'2023 19.4 paragraph 5: "If integer-type-spec appears in data-implied-do or
|
|
|
|
|
ac-implied-do-control it has the specified type and type parameters; otherwise
|
|
|
|
|
it has the type and type parameters that it would have if it were the name of
|
|
|
|
|
a variable in the innermost executable construct or scoping unit that includes
|
|
|
|
|
the DATA statement or array constructor, and this type shall be integer type."
|
|
|
|
|
Reading "would have if it were" as being the subjunctive, this would mean that
|
|
|
|
|
an untyped implied DO index variable should be implicitly typed according to
|
|
|
|
|
the rules active in the enclosing scope. But all other Fortran compilers interpret
|
|
|
|
|
the "would have if it were" as meaning "has if it is" -- i.e., if the name
|
|
|
|
|
is visible in the enclosing scope, the type of that name is used as the
|
|
|
|
|
type of the implied DO index. So this is an error, not a simple application
|
|
|
|
|
of the default implicit typing rule:
|
|
|
|
|
```
|
|
|
|
|
character j
|
|
|
|
|
print *, [(j,j=1,10)]
|
|
|
|
|
```
|
|
|
|
|
|
2024-10-03 10:56:01 +09:00
|
|
|
* The Fortran standard doesn't mention integer overflow explicitly. In many cases,
|
|
|
|
|
however, integer overflow makes programs non-conforming.
|
|
|
|
|
F18 follows other widely-used Fortran compilers. Specifically, f18 assumes
|
|
|
|
|
integer overflow never occurs in address calculations and increment of
|
|
|
|
|
do-variable unless the option `-fwrapv` is enabled.
|
|
|
|
|
|
2025-02-24 10:50:03 -05:00
|
|
|
* Two new ieee_round_type values were added in f18 beyond the four values
|
|
|
|
|
defined in f03 and f08: ieee_away and ieee_other. Contemporary hardware
|
|
|
|
|
typically does not have support for these rounding modes;
|
|
|
|
|
ieee_support_rounding calls for these values return false.
|
|
|
|
|
ieee_set_rounding_mode calls that attempt to set the rounding mode to one
|
|
|
|
|
of these values in violation of the restriction in f23 clause 17.11.42 set
|
|
|
|
|
the mode to ieee_nearest.
|
|
|
|
|
|
2025-04-14 09:00:12 -07:00
|
|
|
* Some compilers allow an `INTENT(OUT)` dummy argument's value to appear
|
|
|
|
|
via host association in a specification expression. A non-host-associated
|
|
|
|
|
use is an error because an `INTENT(OUT)` dummy argument's value is not
|
|
|
|
|
defined. The argument put forth to accept this usage in a `BLOCK` construct
|
|
|
|
|
or inner procedure is that the language in 10.1.11 (specification expressions)
|
|
|
|
|
allows any host-associated object to appear, but that's unconvincing
|
|
|
|
|
because it would also allow a host-associated `OPTIONAL` dummy argument to
|
|
|
|
|
be used in a nested scope, and that doesn't make sense. This compiler
|
|
|
|
|
accepts an `INTENT(OUT)` non-`OPTIONAL` host-associated value to appear
|
|
|
|
|
in a specification expression via host association with a portability
|
|
|
|
|
warning since such values may have become defined by the time the nested
|
|
|
|
|
expression's value is required.
|
|
|
|
|
|
[flang] Restructure runtime to avoid recursion (relanding) (#143993)
Recursion, both direct and indirect, prevents accurate stack size
calculation at link time for GPU device code. Restructure these
recursive (often mutually so) routines in the Fortran runtime with new
implementations based on an iterative work queue with
suspendable/resumable work tickets: Assign, Initialize, initializeClone,
Finalize, and Destroy.
Default derived type I/O is also recursive, but already disabled. It can
be added to this new framework later if the overall approach succeeds.
Note that derived type FINAL subroutine calls, defined assignments, and
defined I/O procedures all perform callbacks into user code, which may
well reenter the runtime library. This kind of recursion is not handled
by this change, although it may be possible to do so in the future using
thread-local work queues.
(Relanding this patch after reverting initial attempt due to some test
failures that needed some time to analyze and fix.)
Fixes https://github.com/llvm/llvm-project/issues/142481.
2025-06-16 14:37:01 -07:00
|
|
|
* Intrinsic assignment of arrays is defined elementally, and intrinsic
|
|
|
|
|
assignment of derived type components is defined componentwise.
|
|
|
|
|
However, when intrinsic assignment takes place for an array of derived
|
|
|
|
|
type, the order of the loop nesting is not defined.
|
|
|
|
|
Some compilers will loop over the elements, assigning all of the components
|
|
|
|
|
of each element before proceeding to the next element.
|
|
|
|
|
This compiler loops over all of the components, and assigns all of
|
|
|
|
|
the elements for each component before proceeding to the next component.
|
|
|
|
|
A program using defined assignment might be able to detect the difference.
|
|
|
|
|
|
2022-12-16 11:44:51 -08:00
|
|
|
## De Facto Standard Features
|
|
|
|
|
|
|
|
|
|
* `EXTENDS_TYPE_OF()` returns `.TRUE.` if both of its arguments have the
|
|
|
|
|
same type, a case that is technically implementation-defined.
|
2023-06-29 15:19:23 -07:00
|
|
|
|
|
|
|
|
* `ENCODING=` is not in the list of changeable modes on an I/O unit,
|
|
|
|
|
but every Fortran compiler allows the encoding to be changed on an
|
|
|
|
|
open unit.
|
2023-07-20 10:39:04 -07:00
|
|
|
|
2024-01-02 09:25:49 -08:00
|
|
|
* A `NAMELIST` input item that references a scalar element of a vector
|
|
|
|
|
or contiguous array can be used as the initial element of a storage
|
|
|
|
|
sequence. For example, "&GRP A(1)=1. 2. 3./" is treated as if had been
|
|
|
|
|
"&GRP A(1:)=1. 2. 3./".
|