This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, fortran] Fix PR 44693


Thomas Koenig wrote:
> OK for trunk?
>   

Not OK - for the reason I was expecting.

-  if (dim->expr_type != EXPR_CONSTANT
-      || (array->expr_type != EXPR_VARIABLE
-	  && array->expr_type != EXPR_ARRAY))
+  if (dim->expr_type != EXPR_CONSTANT)
     return SUCCESS;


This part is OK. While the following does not make sense at all:

-  rank = array->rank;
+  if (array->expr_type == EXPR_FUNCTION && array->value.function.isym)
+    {
+
+      /* Functions which reduce the rank of their arguments.  */
+      switch(array->value.function.isym->id)
+	{
+	case GFC_ISYM_SUM:
+	case GFC_ISYM_PRODUCT:
+	case GFC_ISYM_ANY:
+	case GFC_ISYM_ALL:
+	case GFC_ISYM_COUNT:
+	case GFC_ISYM_MINVAL:
+	case GFC_ISYM_MAXVAL:
+	  rank = array->rank + 1;
+	  break;
+
+	default:
+	  rank = array->rank;
+	}
+    }
+  else
+    {
+      rank = array->rank;
+    }
+


Example:

real :: a(3,3,3)
a = 5.0
print *, sum(sum(a,dim=1), dim=3) 
end

That code is invalid as "sum" only returns a rank 2 array, but due to
the increment of the rank in the second part of your patch, this is not
rejected.

How about using only the first part of your patch - and keep the old and
simple
  rank = array->rank;

OK if you do this and add the add the new example to the test file.

Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]