aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/resolve.c
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2016-11-20 18:43:16 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2016-11-20 18:43:16 +0000
commit8dc998fb42ad043e3a0bfc8f36af07613121b3d4 (patch)
tree5bc304c30af68b1953553c75e35f14a2b27d2a14 /gcc/fortran/resolve.c
parent9692308d305f083785c41596328a35e9fddded8f (diff)
downloadgcc-8dc998fb42ad043e3a0bfc8f36af07613121b3d4.zip
gcc-8dc998fb42ad043e3a0bfc8f36af07613121b3d4.tar.gz
gcc-8dc998fb42ad043e3a0bfc8f36af07613121b3d4.tar.bz2
re PR fortran/69741 (Bad error in forall with array loop counters)
2016-11-20 Harald Anlauf <anlauf@gmx.de> PR fortran/69741 * resolve.c (gfc_resolve_forall): Check for nonscalar index variables. 2016-11-20 Harald Anlauf <anlauf@gmx.de> PR fortran/69741 * gfortran.dg/forall_18.f90: New testcase. From-SVN: r242641
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r--gcc/fortran/resolve.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 589a673..9e628f1 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -9647,16 +9647,15 @@ gfc_resolve_forall (gfc_code *code, gfc_namespace *ns, int forall_save)
static gfc_expr **var_expr;
static int total_var = 0;
static int nvar = 0;
- int old_nvar, tmp;
+ int i, old_nvar, tmp;
gfc_forall_iterator *fa;
- int i;
old_nvar = nvar;
/* Start to resolve a FORALL construct */
if (forall_save == 0)
{
- /* Count the total number of FORALL index in the nested FORALL
+ /* Count the total number of FORALL indices in the nested FORALL
construct in order to allocate the VAR_EXPR with proper size. */
total_var = gfc_count_forall_iterators (code);
@@ -9664,19 +9663,25 @@ gfc_resolve_forall (gfc_code *code, gfc_namespace *ns, int forall_save)
var_expr = XCNEWVEC (gfc_expr *, total_var);
}
- /* The information about FORALL iterator, including FORALL index start, end
- and stride. The FORALL index can not appear in start, end or stride. */
+ /* The information about FORALL iterator, including FORALL indices start, end
+ and stride. An outer FORALL indice cannot appear in start, end or stride. */
for (fa = code->ext.forall_iterator; fa; fa = fa->next)
{
+ /* Fortran 20008: C738 (R753). */
+ if (fa->var->ref && fa->var->ref->type == REF_ARRAY)
+ {
+ gfc_error ("FORALL index-name at %L must be a scalar variable "
+ "of type integer", &fa->var->where);
+ continue;
+ }
+
/* Check if any outer FORALL index name is the same as the current
one. */
for (i = 0; i < nvar; i++)
{
if (fa->var->symtree->n.sym == var_expr[i]->symtree->n.sym)
- {
- gfc_error ("An outer FORALL construct already has an index "
- "with this name %L", &fa->var->where);
- }
+ gfc_error ("An outer FORALL construct already has an index "
+ "with this name %L", &fa->var->where);
}
/* Record the current FORALL index. */