summaryrefslogtreecommitdiff
path: root/flang/lib/Support/Fortran-features.cpp
AgeCommit message (Collapse)Author
2025-08-15[flang] Adding support of -fcoarray flang and init PRIF (#151675)Jean-Didier PAILLEUX
In relation to the approval and merge of the [PRIF](https://github.com/llvm/llvm-project/pull/76088) specification about multi-image features in Flang, here is a first PR to add support for the `-fcoarray` compilation flag and the initialization of the PRIF environment. Other PRs will follow for adding support of lowering to PRIF.
2025-08-13[flang] Warn about inexact real literal implicit widening pitfall (#152799)Peter Klausler
When a REAL or COMPLEX literal appears without an explicit kind suffix or a kind-determining exponent letter, and the conversion of that literal from decimal to binary is inexact, emit a warning if that constant is later implicitly widened to a more precise kind, since it will have a different value than was probably intended. Values that convert exactly from decimal to default real, e.g. 1.0 and 0.125, do not elicit this warning. There are many contexts in which Fortran implicitly converts constants. This patch covers name constant values, variable and component initialization, constants in expressions, structure constructor components, and array constructors. For example, "real(8) :: tenth = 0.1" is a common Fortran bug that's hard to find, and is one that often trips up even experienced Fortran programmers. Unlike C and C++, the literal constant 0.1 is *not* double precision by default, and it does not have the same value as 0.1d0 or 0.1_8 do when it is converted from decimal to real(4) and then to real(8).
2025-07-14[flang] Extension: TRANSFER(boz, integer or real scalar) (#147604)Peter Klausler
Interpret TRANSFER(SOURCE=BOZ literal, MOLD=integer or real scalar) as if it had been a reference to the standard INT or REAL intrinsic functions, for which a BOZ literal is an acceptable argument, with a warning about non-conformance. It's a needless extension that has somehow crept into some other compilers and real applications.
2025-06-30[flang][CLI] Have the CLI hint the flag to disable a warning (#144767)Andre Kuhlenschmidt
Adds a hint to the warning message to disable a warning and updates the tests to expect this. Also fixes a bug in the storage of canonical spelling of error flags so that they are not used after free.
2025-06-18[flang][driver] add ability to look up feature flags without setting them ↵Andre Kuhlenschmidt
(#144559) This just adds some convenience methods to feature control and rewrites old code in terms of those methods. Also cleans up some names that I just realize were overloads of another method.
2025-06-10[flang][cli] Add diagnostic flags to the CLI (#142022)Andre Kuhlenschmidt
This change allows the flang CLI to accept `-W[no-]<feature>` flags matching the clang syntax and enable and disable usage and language feature warnings.
2025-05-13[flang] Acknowledge non-enforcement of C7108 (#139169)Peter Klausler
Fortran 2023 constraint C7108 prohibits the use of a structure constructor in a way that is ambiguous with a generic function reference (intrinsic or user-defined). Sadly, no Fortran compiler implements this constraint, and the common portable interpretation seems to be the generic resolution, not the structure constructor. Restructure the processing of structure constructors in expression analysis so that it can be driven both from the parse tree as well as from generic resolution, and then use it to detect ambigous structure constructor / generic function cases, so that a portability warning can be issued. And document this as a new intentional violation of the standard in Extensions.md. Fixes https://github.com/llvm/llvm-project/issues/138807.
2025-05-01[flang][frontend] warn when a volatile target is pointer associated with an ↵Andre Kuhlenschmidt
non-volatile pointer (#136778) closes #135805
2025-04-14[flang] Allow host-associated INTENT(OUT) in specification expr. (#135426)Peter Klausler
Nearly, but not all, other compilers have a blanket prohibition against the use of an INTENT(OUT) dummy argument in a specification expression. Some compilers, however, permit an INTENT(OUT) dummy argument to appear in a specification expression in a BLOCK construct or inner procedure via host association. The argument some have put forth to accept this usage comes from a reading of 10.1.11 (specification expressions) in Fortran 2023 that, if followed consistently, would also require host-associated OPTIONAL dummy argument to be allowed. That would be dangerous for reasons that should be obvious. However, I can agree that a non-OPTIONAL dummy argument can't be assumed to remain undefined on entry to a BLOCK construct or inner procedure, so we can accept host-associated INTENT(OUT) in specification expressions with a portability warning.
2025-04-04[flang] Permit unused USE association of subprogram name (#134009)Peter Klausler
A function or subroutine can allow an object of the same name to appear in its scope, so long as the name is not used. This is similar to the case of a name being imported from multiple distinct modules, and implemented by the same representation. It's not clear whether this is conforming behavior or a common extension.
2025-02-27[flang] Refine handling of NULL() actual to non-optional allocatable … ↵Peter Klausler
(#116126) …dummy We presently allow a NULL() actual argument to associate with a non-optional dummy allocatable argument only under INTENT(IN). This is too strict, as it precludes the case of a dummy argument with default intent. Continue to require that the actual argument be definable under INTENT(OUT) and INTENT(IN OUT), and (contra XLF) interpret NULL() as being an expression, not a definable variable, even when it is given an allocatable MOLD. Fixes https://github.com/llvm/llvm-project/issues/115984.
2025-02-06[Flang] Move non-common headers to FortranSupport (#124416)Michael Kruse
Move non-common files from FortranCommon to FortranSupport (analogous to LLVMSupport) such that * declarations and definitions that are only used by the Flang compiler, but not by the runtime, are moved to FortranSupport * declarations and definitions that are used by both ("common"), the compiler and the runtime, remain in FortranCommon * generic STL-like/ADT/utility classes and algorithms remain in FortranCommon This allows a for cleaner separation between compiler and runtime components, which are compiled differently. For instance, runtime sources must not use STL's `<optional>` which causes problems with CUDA support. Instead, the surrogate header `flang/Common/optional.h` must be used. This PR fixes this for `fast-int-sel.h`. Declarations in include/Runtime are also used by both, but are header-only. `ISO_Fortran_binding_wrapper.h`, a header used by compiler and runtime, is also moved into FortranCommon.