[flang-commits] [PATCH] D150180: [flang] Ensure pointer components are always established

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue May 9 00:40:37 PDT 2023


jeanPerier created this revision.
jeanPerier added reviewers: Renaud-K, vzakhari, klausler.
jeanPerier added a project: Flang.
Herald added subscribers: sunshaoce, mehdi_amini, jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.

Follow up of https://reviews.llvm.org/D149979 for lowering.

In Fortran, it is possible to assign a pointer to another pointer
with an undefined association status.
When using the runtime do to none trivial pointer association, if the
descriptor are garbage, the runtime cannot safely detect that it has
a garbage descriptor, and it cannot safely know the descriptor size
leading to undefined behavior.
Another reason to initialize descriptor of pointers is to record any
non deferred length parameter value.
Hence, although this is not required by Fortran, f18 always initialize
pointers to NULL().
This was already done in lowering for whole pointer object, but not for
pointer components.

This patch uses the related semantics patch that updated
derivedTypeSpe::HasDefaultInitialization to ensure pointer components
of local and global object are always initialized.

It adds tests to ensure that allocation of such derived type uses the
runtime to ensure the storage is initialized, and that structure
constructors are setting the descriptor component to NULL() if no
initial target is given.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150180

Files:
  flang/lib/Lower/ConvertVariable.cpp
  flang/test/Lower/call-copy-in-out.f90
  flang/test/Lower/pointer-default-init.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150180.520614.patch
Type: text/x-patch
Size: 8477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230509/0321e085/attachment.bin>


More information about the flang-commits mailing list