Bug 32906 - Error: Parameter array ... cannot be automatic or assumed shape
Error: Parameter array ... cannot be automatic or assumed shape
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.2.1
: P3 normal
: 4.3.0
Assigned To: Daniel Franke
http://gcc.gnu.org/ml/gcc-patches/200...
: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-07-26 17:31 UTC by Florian Ladstaedter
Modified: 2007-07-29 14:19 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.0
Known to fail: 4.1.2 4.2.1
Last reconfirmed: 2007-07-26 17:50:34


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Ladstaedter 2007-07-26 17:31:18 UTC
--------------------------------------------
program test_gfortran

implicit none

   !test case 1, similar to PR26074
   integer, parameter :: len = 1
   integer, parameter :: arr(max(len,1)) = (/1/)

   !test case 2
   character(len=*), dimension (1),             parameter :: specStr = (/'string'/)
   double precision, dimension (size(specStr)), parameter :: specNum = (/99.0d0/)

end
--------------------------------------------



This results in:

--------------------------------------------
$gfortran-4.2 -c  test_gfortran.f90
test_gfortran.f90:7.39:

   integer,parameter :: arr(max(len,1)) = (/1/)
                                      1
Error: Parameter array 'arr' at (1) cannot be automatic or assumed shape
test_gfortran.f90:11.68:

   double precision, dimension (size(specStr)), parameter :: specNum = (/99.0d0
                                                                   1
Error: Parameter array 'specnum' at (1) cannot be automatic or assumed shape
--------------------------------------------



This is somehow similar to PR26074 (which is fixed and works). NAG and Lahey Fortran compiler work with this code. See http://gcc.gnu.org/ml/fortran/2007-07/msg00486.html
Comment 1 Daniel Franke 2007-07-26 17:39:33 UTC
Confirmed.

PR26974 has:
  integer, parameter :: len = 1
  integer :: arr(max(len,1)) = (/1/)

Above testcase contains:
  integer, parameter :: len = 1
  integer, parameter :: arr(max(len,1)) = (/1/)
Comment 2 Daniel Franke 2007-07-29 14:18:09 UTC
Subject: Bug 32906

Author: dfranke
Date: Sun Jul 29 14:17:59 2007
New Revision: 127043

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127043
Log:
gcc/fortran:
2007-07-29  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/32906
	* resolve.c (resolve_fl_parameter): Check for constant shape arrays,
	adjusted error message.

gcc/testsuite:
2007-07-29  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/32906
	* gfortran.dg/shape_1.f90: Adjust error message.
	* gfortran.dg/parameter_array_ref_1.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/parameter_array_ref_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/shape_1.f90

Comment 3 Daniel Franke 2007-07-29 14:19:01 UTC
Thanks for the report!
Fixed in trunk. Closing.
Comment 4 Daniel Franke 2007-07-29 14:19:59 UTC
Closing, take II.