diff options
author | Harald Anlauf <anlauf@gmx.de> | 2019-02-26 20:03:08 +0000 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2019-02-26 20:03:08 +0000 |
commit | e6f01a72aef9c28c19d33801dad105a1f0f2b569 (patch) | |
tree | b8891f2858c1ba59fd45b7a9eba9d7b0b30e275e /gcc/fortran/check.c | |
parent | 527a59ff66cc0e4288a69a31b811701bda385838 (diff) |
2019-02-26 Harald Anlauf <anlauf@gmx.de>
PR fortran/89492
* check.c (gfc_calculate_transfer_sizes): Handle cases where
storage size of elements of MOLD is 0.
PR fortran/89492
* gfortran.dg/pr89492.f90: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@269227 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/check.c')
-rw-r--r-- | gcc/fortran/check.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 0367c92ed4b..c5f6ae300a7 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -5487,6 +5487,26 @@ gfc_calculate_transfer_sizes (gfc_expr *source, gfc_expr *mold, gfc_expr *size, if (!gfc_element_size (mold, &result_elt_size)) return false; + if (result_elt_size == 0 && *source_size > 0) + { + gfc_error ("%<MOLD%> argument of %<TRANSFER%> intrinsic at %L " + "shall not have storage size 0 when %<SOURCE%> " + "argument has size greater than 0", &mold->where); + return false; + } + + /* If MOLD is a scalar and SIZE is absent, the result is a scalar. + * If MOLD is an array and SIZE is absent, the result is an array and of + * rank one. Its size is as small as possible such that its physical + * representation is not shorter than that of SOURCE. + */ + if (result_elt_size == 0 && *source_size == 0 && !size) + { + *result_size = 0; + *result_length_p = 0; + return true; + } + if ((result_elt_size > 0 && (mold->expr_type == EXPR_ARRAY || mold->rank)) || size) { |