aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/check.c
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2019-02-26 20:03:08 +0000
committerHarald Anlauf <anlauf@gcc.gnu.org>2019-02-26 20:03:08 +0000
commitec2d749a10606629e257ff6e7a7435289c9068d8 (patch)
treeb8891f2858c1ba59fd45b7a9eba9d7b0b30e275e /gcc/fortran/check.c
parente5bf8dee56aaf4c489a1f3ceca04a8fcd1d2665a (diff)
downloadgcc-ec2d749a10606629e257ff6e7a7435289c9068d8.zip
gcc-ec2d749a10606629e257ff6e7a7435289c9068d8.tar.gz
gcc-ec2d749a10606629e257ff6e7a7435289c9068d8.tar.bz2
re PR fortran/89492 (Endless compilation of an invalid TRANSFER after r269177)
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. From-SVN: r269227
Diffstat (limited to 'gcc/fortran/check.c')
-rw-r--r--gcc/fortran/check.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 0367c92..c5f6ae3 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)
{