diff options
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 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) { |