With gfortran 4.3.0 20080109 I get an incorrect error message "Error: 'source' argument of 'shape' intrinsic at (1) must not be an assumed size array" with the following little test case subroutine j_assumed_size(A,N) dimension A(10,11,12,*) k = shape(A(:,:,:,N)) l = shape(A(:,:,:,3)) end I believe assumed size arrays are allowed provided the last subscript is specified. Dick Hendrickson
Confirm, though your reduced test case is invalid (the variables k and l need to be arrays. Corrected test case: subroutine j_assumed_size(A,N) dimension A(10,11,12,*), k(3), l(3) k = shape(A(:,:,:,N)) l = shape(A(:,:,:,3)) end "SOURCE may be of any type. It may be a scalar or an array. It shall not be an unallocated allocatable or a pointer that is not associated. It shall not be an assumed-size array." The shall-nots do not apply for the rank-3 arrays A(:,:,:,N) and A(:,:,:,3). Actually, this could be a wider problem, which is not only limited to check.c's gfc_check_shape. (For actual/dummy argument checking, I added a note to PR 34665.) Thanks for the report.
Patch. I think this is the only place to change, interface's compare_actual_formal is actually ok. Index: gcc/fortran/check.c =================================================================== --- gcc/fortran/check.c (revision 131492) +++ gcc/fortran/check.c (working copy) @@ -2394,7 +2394,7 @@ gfc_check_shape (gfc_expr *source) ar = gfc_find_array_ref (source); - if (ar->as && ar->as->type == AS_ASSUMED_SIZE) + if (ar->as && ar->as->type == AS_ASSUMED_SIZE && ar->type == AR_FULL) { gfc_error ("'source' argument of 'shape' intrinsic at %L must not be " "an assumed size array", &source->where);
Patch: http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00566.html
Subject: Bug 34759 Author: burnus Date: Sun Jan 13 21:28:30 2008 New Revision: 131511 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131511 Log: 2008-01-13 Tobias Burnus <burnus@net-b.de> PR fortran/34759 * check.c (gfc_check_shape): Accept array ranges of assumed-size arrays. 2008-01-13 Tobias Burnus <burnus@net-b.de> PR fortran/34759 * gfortran.dg/assumed_size_refs_4.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/assumed_size_refs_4.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/check.c trunk/gcc/testsuite/ChangeLog
Fixed on the trunk (4.3.0). Thanks for the report!