[flang-commits] [PATCH] D139155: [flang] Emit errors and warnings about DIM= arguments to intrinsic functions

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Dec 1 15:58:34 PST 2022


klausler created this revision.
klausler added a reviewer: jeanPerier.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a project: All.
klausler requested review of this revision.

The semantics of many transformational intrinsic functions, especially
reductions like SUM(), are determined by the static presence or absence
of a DIM= argument.  In the case of an actual DIM= argument that is
syntactically present but could be dynamically absent at execution time
(due to being OPTIONAL, POINTER, or ALLOCATABLE), f18 should emit some
kind of diagnostic message.

Other compilers either ignore this possibility or treat it as a hard
error; neither really seems correct, so let's do something more nuanced.

For cases where the dynamic absence of a value for DIM doesn't pose
as much of a risk because it lowering is going to assume that it's
equal to 1 anyway, emit only a portability warning.

For other cases where the generated code or runtime support library
will need the value of DIM= during execution, emit a warning that
the use of an OPTIONAL/POINTER/ALLOCATABLE variable or component
here is dicey and should be reconsidered.

While here, also catch bad constant DIM= values.


https://reviews.llvm.org/D139155

Files:
  flang/include/flang/Evaluate/fold.h
  flang/include/flang/Evaluate/tools.h
  flang/lib/Evaluate/fold-implementation.h
  flang/lib/Evaluate/fold-integer.cpp
  flang/lib/Evaluate/fold.cpp
  flang/lib/Evaluate/intrinsics.cpp
  flang/lib/Evaluate/tools.cpp
  flang/test/Lower/transformational-intrinsics.f90
  flang/test/Semantics/dim01.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139155.479462.patch
Type: text/x-patch
Size: 14846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221201/813adf68/attachment-0001.bin>


More information about the flang-commits mailing list