[flang-commits] [PATCH] D122899: [flang] add evaluate::IsAllocatable helper

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Apr 1 05:53:47 PDT 2022


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

Previously, some semantic checks that are checking if an entity is an
allocatable were relying on the expression being a designator whose
last symbol has the allocatable attribute.

This is wrong since this was considering substrings and array sections of
allocatables as being allocatable. This is wrong (see NOTE 2 in
Fortran 2018 section 9.5.3).

Add evaluate::IsAllocatable to correctly test this.
Also add some semantic tests for ALLOCATED to test the newly added helper.
Note that ifort and nag are rejecting coindexed-named-object in
ALLOCATED (`allocated(coarray_scalar_alloc[2])`).
I think it is wrong given allocated argument is intent(in) as per
16.2.1 point 3.
So 15.5.2.6 point 4 regarding allocatable dummy is not violated (If the actual
argument is a coindexed object, the dummy argument shall have the INTENT (IN)
attribute.) and I think this is valid. gfortran accepts it.

The need for this helper was exposed in https://reviews.llvm.org/D122779.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122899

Files:
  flang/include/flang/Evaluate/tools.h
  flang/lib/Evaluate/intrinsics.cpp
  flang/lib/Evaluate/tools.cpp
  flang/lib/Semantics/check-call.cpp
  flang/test/Semantics/allocated.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122899.419733.patch
Type: text/x-patch
Size: 5859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220401/d0466228/attachment.bin>


More information about the flang-commits mailing list