[patch, fortran] PR32906 - Parameter array ... cannot be automatic or assumed shape
Paul Thomas
paulthomas2@wanadoo.fr
Sun Jul 29 13:40:00 GMT 2007
Daniel,
Since I had a hand in the original, it's only fitting that I....
>
> Regression tested on i686-pc-linux-gnu. Ok for trunk?
>
....OK the correction:)
Could you add ADDPATCH fortran to the top of your submissions, please?
It triggers off the automatic patch tracking.
Thanks
Paul
> Regards
> Daniel
>
>
> ------------------------------------------------------------------------
>
> Index: fortran/resolve.c
> ===================================================================
> --- fortran/resolve.c (revision 126930)
> +++ fortran/resolve.c (working copy)
> @@ -7098,10 +7112,12 @@
> resolve_fl_parameter (gfc_symbol *sym)
> {
> /* A parameter array's shape needs to be constant. */
> - if (sym->as != NULL && !gfc_is_compile_time_shape (sym->as))
> + if (sym->as != NULL
> + && (sym->as->type == AS_DEFERRED
> + || is_non_constant_shape_array (sym)))
> {
> gfc_error ("Parameter array '%s' at %L cannot be automatic "
> - "or assumed shape", sym->name, &sym->declared_at);
> + "or of deferred shape", sym->name, &sym->declared_at);
> return FAILURE;
> }
> .....
> Index: testsuite/gfortran.dg/shape_1.f90
> ===================================================================
> --- testsuite/gfortran.dg/shape_1.f90 (revision 126930)
> +++ testsuite/gfortran.dg/shape_1.f90 (working copy)
> @@ -1,6 +1,6 @@
> ! { dg-do compile }
> ! PR 13201 we used to not give an error in those cases
> subroutine foo(n)
> - integer, parameter :: a(n) = 1 ! { dg-error "cannot be automatic" "automatic shape" }
> - integer, parameter :: z(:) = (/ 1,2,3 /) ! { dg-error "cannot be automatic" "assumed shape" }
> + integer, parameter :: a(n) = 1 ! { dg-error "cannot be automatic" "automatic shape" }
> + integer, parameter :: z(:) = (/ 1,2,3 /) ! { dg-error "cannot be automatic" "deferred shape" }
> end subroutine
> Index: testsuite/gfortran.dg/parameter_array_ref_1.f90
> ===================================================================
> --- testsuite/gfortran.dg/parameter_array_ref_1.f90 (revision 0)
> +++ testsuite/gfortran.dg/parameter_array_ref_1.f90 (revision 0)
> @@ -0,0 +1,13 @@
> +! { dg-do compile }
> +!
> +! PR fortran/32906 - Parameter array ... cannot be automatic or assumed shape
> +!
> +! Testcase contributed by Florian Ladstaedter <flad AT gmx DOT at>
> +!
> +program test_program
> + integer, parameter :: len = 1
> + integer, parameter :: arr(max(len,1)) = (/1/)
> +
> + character(len=*), dimension (1), parameter :: specStr = (/'string'/)
> + double precision, dimension (size(specStr)), parameter :: specNum = (/99.0d0/)
> +end
>
More information about the Gcc-patches
mailing list