]> git.ipfire.org Git - thirdparty/gcc.git/commit
Make STAT and ERRMSG work on ALLOCATE, move error handling to library.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 30 Dec 2020 16:53:31 +0000 (17:53 +0100)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 30 Dec 2020 16:53:31 +0000 (17:53 +0100)
commit4726e39b0be3c0bc55e43d2d300f0d0b9529d883
treee43bd7824dec4baaae0482ee651d239e2840c684
parent2b0eabeb48d63234a3dbaad9c1f4d81305439b3e
Make STAT and ERRMSG work on ALLOCATE, move error handling to library.

This makes STAT and ERRMSG work on ALLOCATE.  It also separates
the allocation of coarrays into two functions: One without error
checking, which is called by compiler-generated code, and one
with error checking for call from user code.

In the course of looking at this, it was also noticed that
allocatable coarrays were not automatically deallocated;
this is now also fixed.  Also, saved allocatable coarrays
are now saved.

gcc/fortran/ChangeLog:

* trans-array.c (gfc_allocate_shared_coarray): Remove extra
arguments, just build the call.
(allocate_shared_coarray_chk): New function.
(gfc_array_allocate): Adjust where to set the offset.
Error handling is done in the library for shared coarrays.
(gfc_trans_deferred_array): No early return for allocatable
shared coarrays.
* trans-array.h (gfc_array_allocate): Adjust prototype.
(gfc_allocate_shared_coarray): Likewise.
* trans-decl.c: Rename gfor_fndecl_cas_coarray_allocate to
gfor_fndecl_cas_coarray_alloc for
brevity.  Add gfor_fndecl_cas_coarray_alloc_chk.
(gfc_build_builtin_function_decls): Likewise.
(gfc_trans_shared_coarray): Adjust calling sequence for
gfc_allocate_shared_coarray.
(gfc_trans_deferred_vars): Correct handling of saved
allocatable shared coarrays.
* trans-stmt.c (gfc_trans_sync): Adjust whitespace.o
(coarray_alloc_p): Remove.
(gfc_trans_allocate): Add shared_coarray variable to adjust
status and errmsg handling.
* trans.h: Rename gfor_fndecl_cas_coarray_allocate to
gfor_fndecl_cas_coarray_alloc for brevity.  Add
gfor_fndecl_cas_coarray_alloc_chk.

libgfortran/ChangeLog:

* caf_shared/coarraynative.c (test_for_cas_errors): Correct
handling of stat.
* caf_shared/libcoarraynative.h (STAT_ERRMSG_ENTRY_CHECK): Use
unlikely in condition.
(STAT_ERRMSG_ENTRY_CHECK_RET): Likewise.
* caf_shared/wrapper.c (cas_coarray_alloc): Adjust arguments.
Call cas_coarray_alloc_work.
(cas_coarray_alloc_chk): New function.
(cas_coarray_alloc_work): New function.

gcc/testsuite/ChangeLog:

* gfortran.dg/caf-shared/allocate_1.f90: Adjust number of calls to
sync_all.
* gfortran.dg/caf-shared/allocate_status_1.f90: New test.
* gfortran.dg/caf-shared/automatic_deallocate_1.f90: New test.
* gfortran.dg/caf-shared/save_allocatable_1.f90: New test.
12 files changed:
gcc/fortran/trans-array.c
gcc/fortran/trans-array.h
gcc/fortran/trans-decl.c
gcc/fortran/trans-stmt.c
gcc/fortran/trans.h
gcc/testsuite/gfortran.dg/caf-shared/allocate_1.f90
gcc/testsuite/gfortran.dg/caf-shared/allocate_status_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/caf-shared/automatic_deallocate_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/caf-shared/save_allocatable_1.f90 [new file with mode: 0644]
libgfortran/caf_shared/coarraynative.c
libgfortran/caf_shared/libcoarraynative.h
libgfortran/caf_shared/wrapper.c