This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fortran] Fix PR 44693
- From: Tobias Burnus <burnus at net-b dot de>
- To: Thomas Koenig <tkoenig at netcologne dot de>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sun, 04 Jul 2010 22:06:35 +0200
- Subject: Re: [patch, fortran] Fix PR 44693
- References: <1278236813.4645.7.camel@linux-fd1f.site>
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