Bug 45689 - [F03] Missing transformational intrinsic in the trans_func_f2003 list
Summary: [F03] Missing transformational intrinsic in the trans_func_f2003 list
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 25104 29962 (view as bug list)
Depends on:
Blocks: F2003 30932 31392
  Show dependency treegraph
 
Reported: 2010-09-16 10:40 UTC by Dominique d'Humieres
Modified: 2016-11-08 14:02 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-06-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominique d'Humieres 2010-09-16 10:40:58 UTC
While playing with modifications of PR4581, I tried

  module m
    implicit none
    type t
      integer :: i
    end type t
    type(t), dimension(2), parameter :: a1  = (/ t(1), t(2) /)
    type(t), dimension(2), parameter :: d = cshift ( a1, 1 )
  end module m

and got

pr45081_red.f90:7.43:

    type(t), dimension(2), parameter :: d = cshift ( a1, 1 )
                                           1
Error: transformational intrinsic 'cshift' at (1) is not permitted in an initialization expression

The F2003 standard says:

(5) A reference to a transformational standard intrinsic function other than NULL, where each argument is an initialization expression,

and the F2008 version adds:

(6) a reference to a transformational standard intrinsic function other than COMMAND ARGUMENT -COUNT, NULL, NUM IMAGES, THIS IMAGE, where each argument is a constant expression,

This is fixed by the following patch:


--- ../_clean/gcc/fortran/expr.c	2010-09-09 21:06:18.000000000 +0200
+++ gcc/fortran/expr.c	2010-09-16 12:24:49.000000000 +0200
@@ -2329,7 +2329,7 @@ check_transformational (gfc_expr *e)
   };
 
   static const char * const trans_func_f2003[] =  {
-    "all", "any", "count", "dot_product", "matmul", "null", "pack",
+    "all", "any", "count", "cshift", "dot_product", "eoshift", "matmul", "null", "pack",
     "product", "repeat", "reshape", "selected_char_kind", "selected_int_kind",
     "selected_real_kind", "spread", "sum", "transfer", "transpose",
     "trim", "unpack", NULL

but then I am back to PR45081!-(even with the Paul's patch).
Comment 1 Dominique d'Humieres 2010-09-16 10:42:02 UTC
pasto!-(
Comment 2 Daniel Franke 2010-09-16 11:14:11 UTC
They are not, as there, afaik, are no simplifiers yet.

Hence, with your patch they will be accepted, but you'd end up with wrong code at the end, as the functions are not properly simplified and thus not constant.
Comment 3 Dominique d'Humieres 2010-09-16 13:09:38 UTC
MAXLOC and MINLOC are also missing (see pr25104).

> They are not, as there, afaik, are no simplifiers yet.
>
> Hence, with your patch they will be accepted, but you'd end up with wrong code
> at the end, as the functions are not properly simplified and thus not constant.

I have seen that, and also in gcc/fortran/simplify.c

    /* FIXME: Returning here avoids a regression in array_simplify_1.f90.
       Replace NULL with gcc_unreachable() after implementing
       gfc_simplify_cshift(). */

Am I correct to understand that the current situation (i.e. the error message) is a temporary fix for some missing gfc_simplify_*?
Comment 4 Daniel Franke 2010-09-18 15:58:30 UTC
(In reply to comment #3)
> Am I correct to understand that the current situation (i.e. the error message)
> is a temporary fix for some missing gfc_simplify_*?

If the error message you refer to is

> Error: transformational intrinsic 'cshift' at (1) is not permitted in an
> initialization expression

then yes.
Comment 5 Dominique d'Humieres 2013-06-16 12:06:54 UTC
Related or duplicate of PR52473.
Comment 6 Dominique d'Humieres 2013-06-25 17:16:29 UTC
From http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29962#c20

Transformational intrinsics, done are:
 * all, any, count
 * product, sum
 * dot_product, matmul, transpose
 * pack, unpack, spread

Left:
 * maxloc, minloc
 * maxval, minval (generic case)
 * cshift, eoshift

While at it, see also PR29600 (kind arguments) and PR36313 (character type).

Earlier this year, I was working on the cshift/eoshift, but I strongly believe that the linear list that builds the constructor must be replaced with splay trees before this can be implemented somewhat efficiently.

I think what is left in pr29962 is a duplicate of this one.
Comment 7 Dominique d'Humieres 2013-06-25 17:17:13 UTC
*** Bug 29962 has been marked as a duplicate of this bug. ***
Comment 8 Dominique d'Humieres 2013-06-25 17:27:45 UTC
*** Bug 25104 has been marked as a duplicate of this bug. ***
Comment 9 Dominique d'Humieres 2015-11-21 20:18:57 UTC
Partial fix done at revision r230709.