summaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authortobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-09 21:20:50 +0000
committertobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-09 21:20:50 +0000
commitc1a3b6650d36a1defa9e50049828459716dbc661 (patch)
treed3352c7a5ccff7412b5e6acf7f1978a0e40eb5b6 /gcc/fortran
parent6a2ba6a93baf120718f6e6fc641ca771b5fb3f96 (diff)
downloadgcc-c1a3b6650d36a1defa9e50049828459716dbc661.tar.gz
PR fortran/13201
* resolve.c (resolve_symbol): Verify that the shape of a parameter array is not only explicit, but also constant. * array.c (gfc_is_compile_time_shape): New function. * gfortran.h (gfc_is_compile_time_shape): Add prototype. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84400 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/array.c19
-rw-r--r--gcc/fortran/gfortran.h1
-rw-r--r--gcc/fortran/resolve.c12
4 files changed, 35 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index d5578cff5ca..26182d4c95b 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,4 +1,12 @@
2004-07-09 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
+
+ PR fortran/13201
+ * resolve.c (resolve_symbol): Verify that the shape of a
+ parameter array is not only explicit, but also constant.
+ * array.c (gfc_is_compile_time_shape): New function.
+ * gfortran.h (gfc_is_compile_time_shape): Add prototype.
+
+2004-07-09 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/15481
PR fortran/13372
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index a7081d84305..c7fc8bbccf7 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -1973,3 +1973,22 @@ gfc_find_array_ref (gfc_expr * e)
return &ref->u.ar;
}
+
+
+/* Find out if an array shape is known at compile time. */
+
+int
+gfc_is_compile_time_shape (gfc_array_spec *as)
+{
+ int i;
+
+ if (as->type != AS_EXPLICIT)
+ return 0;
+
+ for (i = 0; i < as->rank; i++)
+ if (!gfc_is_constant_expr (as->lower[i])
+ || !gfc_is_constant_expr (as->upper[i]))
+ return 0;
+
+ return 1;
+}
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 54508dc590e..d82d30621d7 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1645,6 +1645,7 @@ void gfc_insert_constructor (gfc_expr *, gfc_constructor *);
gfc_constructor *gfc_get_constructor (void);
tree gfc_conv_array_initializer (tree type, gfc_expr * expr);
try spec_size (gfc_array_spec *, mpz_t *);
+int gfc_is_compile_time_shape (gfc_array_spec *);
/* interface.c -- FIXME: some of these should be in symbol.c */
void gfc_free_interface (gfc_interface *);
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index a10709504f9..81df9ef03f8 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -3745,12 +3745,14 @@ resolve_symbol (gfc_symbol * sym)
return;
}
- if (sym->attr.flavor == FL_PARAMETER
- && sym->as != NULL && sym->as->type != AS_EXPLICIT)
+ /* A parameter array's shape needs to be constant. */
+
+ if (sym->attr.flavor == FL_PARAMETER && sym->as != NULL
+ && !gfc_is_compile_time_shape (sym->as))
{
- gfc_error ("Parameter array '%s' at %L must have an explicit shape",
- sym->name, &sym->declared_at);
- return;
+ gfc_error ("Parameter array '%s' at %L cannot be automatic "
+ "or assumed shape", sym->name, &sym->declared_at);
+ return;
}
/* Make sure that character string variables with assumed length are