aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2007-04-15 15:28:06 +0000
committerPaul Thomas <pault@gcc.gnu.org>2007-04-15 15:28:06 +0000
commit9a3db5a366f36a48e6879ed17b9c5dbf87442808 (patch)
tree998d5a983b982f9cb8acff35d3022b8d994d5cd2 /gcc/fortran
parente3e093eceff3da3fa4aa20745d2e3fb2d3b6e519 (diff)
downloadgcc-9a3db5a366f36a48e6879ed17b9c5dbf87442808.zip
gcc-9a3db5a366f36a48e6879ed17b9c5dbf87442808.tar.gz
gcc-9a3db5a366f36a48e6879ed17b9c5dbf87442808.tar.bz2
re PR fortran/31204 (wrong host association of implied loop variable)
2007-04-15 Paul Thomas <pault@gcc.gnu.org> PR fortran/31204 * primary.c (check_for_implicit_index): New function to check that a host associated variable is not an undeclared implied do loop index. (gfc_match_rvalue, match_variable): Use it and reset the implied_index attribute. * gfortran.h : Add the implied_index field to symbol_attribute. * match.c (gfc_match_iterator): Mark the iterator variable with the new attribute. * decl.c (build_sym): Reset the new attribute. 2007-04-15 Paul Thomas <pault@gcc.gnu.org> PR fortran/31204 * gfortran.dg/array_constructor_16.f90: New test. From-SVN: r123849
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog13
-rw-r--r--gcc/fortran/decl.c2
-rw-r--r--gcc/fortran/match.c2
-rw-r--r--gcc/fortran/primary.c38
4 files changed, 55 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 3d8b03c..b6a3b29 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,16 @@
+2007-04-15 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/31204
+ * primary.c (check_for_implicit_index): New function to check
+ that a host associated variable is not an undeclared implied
+ do loop index.
+ (gfc_match_rvalue, match_variable): Use it and reset the
+ implied_index attribute.
+ * gfortran.h : Add the implied_index field to symbol_attribute.
+ * match.c (gfc_match_iterator): Mark the iterator variable
+ with the new attribute.
+ * decl.c (build_sym): Reset the new attribute.
+
2007-04-15 Kazu Hirata <kazu@codesourcery.com>
* gfc-internals.texi: Fix typos.
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 9b54bca..7665bc8 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -769,6 +769,8 @@ build_sym (const char *name, gfc_charlen *cl,
if (gfc_copy_attr (&sym->attr, &attr, var_locus) == FAILURE)
return FAILURE;
+ sym->attr.implied_index = 0;
+
return SUCCESS;
}
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 2483ea3..c2c239d 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -536,6 +536,8 @@ gfc_match_iterator (gfc_iterator *iter, int init_flag)
goto cleanup;
}
+ var->symtree->n.sym->attr.implied_index = 1;
+
m = init_flag ? gfc_match_init_expr (&e1) : gfc_match_expr (&e1);
if (m == MATCH_NO)
goto syntax;
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index 9e27edc..41c7507 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -1989,6 +1989,28 @@ cleanup:
}
+/* If the symbol is an implicit do loop index and implicitly typed,
+ it should not be host associated. Provide a symtree from the
+ current namespace. */
+static match
+check_for_implicit_index (gfc_symtree **st, gfc_symbol **sym)
+{
+ if ((*sym)->attr.flavor == FL_VARIABLE
+ && (*sym)->ns != gfc_current_ns
+ && (*sym)->attr.implied_index
+ && (*sym)->attr.implicit_type
+ && !(*sym)->attr.use_assoc)
+ {
+ int i;
+ i = gfc_get_sym_tree ((*sym)->name, NULL, st);
+ if (i)
+ return MATCH_ERROR;
+ *sym = (*st)->n.sym;
+ }
+ return MATCH_YES;
+}
+
+
/* Matches a variable name followed by anything that might follow it--
array reference, argument list of a function, etc. */
@@ -2024,7 +2046,14 @@ gfc_match_rvalue (gfc_expr **result)
e = NULL;
where = gfc_current_locus;
+ /* If this is an implicit do loop index and implicitly typed,
+ it should not be host associated. */
+ m = check_for_implicit_index (&symtree, &sym);
+ if (m != MATCH_YES)
+ return m;
+
gfc_set_sym_referenced (sym);
+ sym->attr.implied_index = 0;
if (sym->attr.function && sym->result == sym)
{
@@ -2394,6 +2423,15 @@ match_variable (gfc_expr **result, int equiv_flag, int host_flag)
where = gfc_current_locus;
sym = st->n.sym;
+
+ /* If this is an implicit do loop index and implicitly typed,
+ it should not be host associated. */
+ m = check_for_implicit_index (&st, &sym);
+ if (m != MATCH_YES)
+ return m;
+
+ sym->attr.implied_index = 0;
+
gfc_set_sym_referenced (sym);
switch (sym->attr.flavor)
{