This is an archive of the discontinued LLVM Phabricator instance.

[flang] Portability warnings for an ambiguous ASSOCIATED() case
ClosedPublic

Authored by klausler on Jan 27 2023, 9:53 AM.

Details

Summary

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.

Diff Detail

Event Timeline

klausler created this revision.Jan 27 2023, 9:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2023, 9:53 AM
klausler requested review of this revision.Jan 27 2023, 9:53 AM
PeteSteinfeld accepted this revision.Jan 27 2023, 11:34 AM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Jan 27 2023, 11:34 AM