Hello,

Le 24/11/2021 à 22:32, Harald Anlauf via Fortran a écrit :
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 5a5aca10ebe..837eb0912c0 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -4866,10 +4868,17 @@ gfc_check_reshape (gfc_expr *source, gfc_expr *shape,
        {
          gfc_constructor *c;
          bool test;
+         gfc_constructor_base b;

+         if (shape->expr_type == EXPR_ARRAY)
+           b = shape->value.constructor;
+         else if (shape->expr_type == EXPR_VARIABLE)
+           b = shape->symtree->n.sym->value->value.constructor;

This misses a check that shape->symtree->n.sym->value is an array, so that it makes sense to access its constructor.

Actually, this only supports the case where the parameter value is defined by an array; but it could be an intrinsic call, a sum of parameters, a reference to an other parameter, etc.

The usual way to handle this is to call gfc_reduce_init_expr which (pray for it) will make an array out of whatever the shape expression is.

The rest looks good.
In the test, can you add a comment telling what it is testing?
Something like: "This tests that constant shape expressions passed to the reshape intrinsic are properly simplified before being used to diagnose invalid values" We also used to put a comment mentioning the person who submitted the test, but not everybody seems to do it these days.

Mikael

Reply via email to