diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2015-05-16 12:33:01 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2015-05-16 12:33:01 +0000 |
commit | 1aae3f05473e1e6bbfb80a9adfbc8cff4a61e310 (patch) | |
tree | 03c12b7dcd2d7bed40f9e13094e8f4ed26459a10 /gcc/fortran/expr.c | |
parent | 2a2703a2bd0046ed60a2054df1f4f3ba5c793062 (diff) | |
download | gcc-1aae3f05473e1e6bbfb80a9adfbc8cff4a61e310.zip gcc-1aae3f05473e1e6bbfb80a9adfbc8cff4a61e310.tar.gz gcc-1aae3f05473e1e6bbfb80a9adfbc8cff4a61e310.tar.bz2 |
re PR fortran/66113 (Variable n cannot appear in the expression with nested blocks)
2015-05-16 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/66113
* expr.c (is_parent_of_current_ns): New function.
(check_restricted): Use it.
2015-05-16 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/66113
* gfortran.dg/block_14.f90: New test.
From-SVN: r223238
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index c34be90..aa79243 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2841,6 +2841,18 @@ check_references (gfc_ref* ref, bool (*checker) (gfc_expr*)) return check_references (ref->next, checker); } +/* Return true if ns is a parent of the current ns. */ + +static bool +is_parent_of_current_ns (gfc_namespace *ns) +{ + gfc_namespace *p; + for (p = gfc_current_ns->parent; p; p = p->parent) + if (ns == p) + return true; + + return false; +} /* Verify that an expression is a restricted expression. Like its cousin check_init_expr(), an error message is generated if we @@ -2929,9 +2941,7 @@ check_restricted (gfc_expr *e) || sym->attr.dummy || sym->attr.implied_index || sym->attr.flavor == FL_PARAMETER - || (sym->ns && sym->ns == gfc_current_ns->parent) - || (sym->ns && gfc_current_ns->parent - && sym->ns == gfc_current_ns->parent->parent) + || is_parent_of_current_ns (sym->ns) || (sym->ns->proc_name != NULL && sym->ns->proc_name->attr.flavor == FL_MODULE) || (gfc_is_formal_arg () && (sym->ns == gfc_current_ns))) |