summaryrefslogtreecommitdiff
path: root/flang/docs
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2023-01-11 14:31:49 -0800
committerPeter Klausler <pklausler@nvidia.com>2023-01-27 16:51:03 -0800
commitaad5984b56280d7dc71a43c258c5ed349c9a239f (patch)
tree33d8f407ee8852c075af621df29591ed3892bda5 /flang/docs
parentb4b9786f4ac4cb2d9b6e7c3ce221b06d21d6ab06 (diff)
downloadllvm-aad5984b56280d7dc71a43c258c5ed349c9a239f.tar.gz
[flang] Portability warnings for an ambiguous ASSOCIATED() case
The standard's specification for the ASSOCIATED() intrinsic function describes its optional second argument (TARGET=) as being required to be a valid target for a pointer assignment statement in which the first argument (POINTER=) was the left-hand side. Some Fortran compilers apparently interpret this text as a requirement that the POINTER= argument actually be a valid left-hand side to a pointer assignment statement, and emit an error if it is not so. This particularly affects the use of an explicit NULL pointer as the first argument. Such usage is well-defined, benign, useful, and supported by at least two other compilers, so we should continue to accept it. This patch adds a portability warning and some documentation. In order to implement the portability warning in the best way, the special checks on calls to the ASSOCIATED() intrinsic function have been moved from intrinsic processing to Semantics/check-calls.cpp, whence they have access to semantics' toolchest. Special checks for other intrinsic functions might also migrate in the future in order to keep them all in one place. Differential Revision: https://reviews.llvm.org/D142768
Diffstat (limited to 'flang/docs')
-rw-r--r--flang/docs/Extensions.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index 31f2fda8c4cc..928fe07a7906 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -527,6 +527,19 @@ end module
scope, with a portability warning, since that global name is not actually
capable of being "used" in its scope.
+* 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.
+
## De Facto Standard Features
* `EXTENDS_TYPE_OF()` returns `.TRUE.` if both of its arguments have the