Hi Paul,
shouldn't this be done in iresolve.cc to make other parts of gfortran benefit
from learning, that the sym is allocatable?
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -3883,6 +3883,13 @@ gfc_conv_intrinsic_funcall (gfc_se * se, gfc_expr *
expr) append_args->quick_push (null_pointer_node);
}
}
+ /* Non-character scalar reduce returns a pointer to a result of size set by
+ the element size of 'array'. Setting 'sym' allocatable ensures that the
+ result is deallocated at the appropriate time. */
+ else if (expr->value.function.isym->id == GFC_ISYM_REDUCE
+ && expr->rank == 0 && expr->ts.type != BT_CHARACTER)
+ sym->attr.allocatable = 1;
+
gfc_conv_procedure_call (se, sym, expr->value.function.actual, expr,
append_args);
--- a/libgfortran/intrinsics/reduce.c
+++ b/libgfortran/intrinsics/reduce.c
@@ -83,8 +83,8 @@ reduce (parray *ret,
if (dim_present)
{
if ((*dim < 1) || (*dim > (GFC_INTEGER_4)array_rank))
- runtime_error ("DIM in REDUCE intrinsic is less than 0 or greater than
"
- "the rank of ARRAY");
+ runtime_error ("Mismatch between DIM in and the rank of ARRAY in the "
... DIM and the rank ... ???
+ "REDUCE intrinsic (%d/%d)", (int)*dim, array_rank);
dimen = (index_type) *dim;
}
else
...
if (masked && (ext != GFC_DESCRIPTOR_EXTENT (mask, i)))
- runtime_error ("shape mismatch between ARRAY and MASK in REDUCE "
- "intrinsic");
+ {
+ int mext = (int)GFC_DESCRIPTOR_EXTENT (mask, i);
+ runtime_error ("shape mismatch between ARRAY and MASK in REDUCE "
+ "intrinsic (%d/%d)", (int)ext, mext);
size_t mext = ...
runtime_error ("... intrinsic (%zd/%d)", ext, mext);
%zd is for size_t and other size related variable-output. It might be more
precise. Just an idea.
Please check your Changelog for style. When I am not mistaken, then a . has to
be followed by two spaces. Or did this change? I like to use git gcc-verify on
my commit message. That points out some easy to spot oversights.
Besides those minor nits: Looks good to me. Ok to merge, when reports have
verified.
Thanks for the patch,
Andre
--
Andre Vehreschild * Email: vehre ad gmx dot de