This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Fix PR 13201
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: GCC Fortran mailing list <fortran at gcc dot gnu dot org>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 31 May 2004 22:54:08 +0200
- Subject: [gfortran] Fix PR 13201
This patch updates the resolution stage to give an error, when a
parameter array is never given an explicit shape. For instance, for the
reduced testcase from the PR instead of ICEing later on, we now give:
[tobi@marktplatz tests]$ cat pr13201_2.f90
program test
integer, parameter :: zeros(:) = (/ 0, 0 /)
call mysub (zeros)
end program
[tobi@marktplatz tests]$ ../gcc/build-clean/gcc/f951 ./pr13201_2.f90
In file ./pr13201_2.f90:2
integer, parameter :: zeros(:) = (/ 0, 0 /)
1
Error: No shape specified for parameter array 'zeros' declared at (1)
Since code generation is not entered after errors in the frontend, the
ICE doesn't happen any longer.
Compiled and tested on i686-pc-linux, the diff also contains a fix for
coding style issues in the lines immediately preceding.
- Tobi
2004-05-31 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/13201
* resolve.c (resolve_symbol): Fix coding style issue. Don't
allow parameter arrays with deferred shape.
Index: resolve.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/resolve.c,v
retrieving revision 1.4
diff -u -p -r1.4 resolve.c
--- resolve.c 18 May 2004 00:48:04 -0000 1.4
+++ resolve.c 31 May 2004 20:37:00 -0000
@@ -3736,9 +3736,17 @@ resolve_symbol (gfc_symbol * sym)
|| sym->as->type == AS_ASSUMED_SHAPE)
&& sym->attr.dummy == 0)
{
- gfc_error("Assumed %s array at %L must be a dummy argument",
- sym->as->type == AS_ASSUMED_SIZE ? "size" : "shape",
- &sym->declared_at);
+ gfc_error ("Assumed %s array at %L must be a dummy argument",
+ sym->as->type == AS_ASSUMED_SIZE ? "size" : "shape",
+ &sym->declared_at);
+ return;
+ }
+
+ if (sym->attr.flavor == FL_PARAMETER
+ && sym->as != NULL && sym->as->type == AS_DEFERRED)
+ {
+ gfc_error ("No shape specified for parameter array '%s' declared
at %L",
+ sym->name, &sym->declared_at);
return;
}