The following should be rejected: program main implicit none integer :: i character(len=3) :: e(2,3,4) e = reshape([(repeat(achar(i),3),i=iachar('a'),iachar('a')+2*3*4-1)], shape(e)) print *,eoshift(e,1,boundary="1") end program main From the F2003 standard 13.7.52: "BOUNDARY (optional) shall be of the same type and type parameters as ARRAY"
Another thing that is incorrectly accepted, also with -fcheck=bounds: program main implicit none integer :: n integer :: i,n1, n2, n3 character(len=3), parameter :: e(2,3,4) = reshape([(repeat(achar(i),3),i=iachar('a'),iachar('a')+2*3*4-1)], & shape(e)) character(len=3), parameter :: bnd2(3,5) = reshape([(repeat(achar(i),3),i=iachar('A'),iachar('A')+3*5-1)], & shape(bnd2)) character(len=3) :: f2(2,3,4) ! = eoshift(e,shift=-1,boundary=bnd2); n = -1 f2 = eoshift(e,shift=n,boundary=bnd2); ! bnd2 has wrong bounds print '(*(1H",A,1H",:","))',f2 end program main
Author: tkoenig Date: Thu Jan 4 21:04:23 2018 New Revision: 256265 URL: https://gcc.gnu.org/viewcvs?rev=256265&root=gcc&view=rev Log: 2018-01-04 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/83683 PR fortran/45689 * check.c (gfc_check_eoshift): Check for string length and for conformance of boundary. * intrinsic.c (add_functions): Add gfc_simplify_eoshift. * intrinsic.h: Add prototype for gfc_simplify_eoshift. * simplify.c (gfc_simplify_eoshift): New function. 2018-01-04 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/83683 PR fortran/45689 * gfortran.dg/eoshift_8.f90: New test. * gfortran.dg/simplify_eoshift_1.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/eoshift_8.f90 trunk/gcc/testsuite/gfortran.dg/simplify_eoshift_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/check.c trunk/gcc/fortran/intrinsic.c trunk/gcc/fortran/intrinsic.h trunk/gcc/fortran/simplify.c trunk/gcc/testsuite/ChangeLog
Fixed, closing.