aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2018-06-09 15:47:40 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2018-06-09 15:47:40 +0000
commit3cf89a7b992d483e80b3b5960f6f4012fae95045 (patch)
tree262502906e56d2b58266b9acc37a80aef7d64e8f /gcc/fortran/decl.c
parent4ea0af1da0cfa9c55e739808d4b405b982985ad5 (diff)
downloadgcc-3cf89a7b992d483e80b3b5960f6f4012fae95045.zip
gcc-3cf89a7b992d483e80b3b5960f6f4012fae95045.tar.gz
gcc-3cf89a7b992d483e80b3b5960f6f4012fae95045.tar.bz2
re PR fortran/85138 (ICE with generic function)
2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * decl.c (gfc_match_char_spec): Use private namespace in attempt to reduce a charlen to a constant. 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * gfortran.dg/pr85138_1.f90: New test. * gfortran.dg/pr85138_2.f90: Ditto. * gfortran.dg/pr85996.f90: Ditto. From-SVN: r261362
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index df21ce0..c36a16b 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -3238,12 +3238,20 @@ done:
cl->length = gfc_get_int_expr (gfc_charlen_int_kind, NULL, 1);
else
{
- /* If gfortran ends up here, then the len may be reducible to a
- constant. Try to do that here. If it does not reduce, simply
- assign len to the charlen. */
+ /* If gfortran ends up here, then len may be reducible to a constant.
+ Try to do that here. If it does not reduce, simply assign len to
+ charlen. A complication occurs with user-defined generic functions,
+ which are not resolved. Use a private namespace to deal with
+ generic functions. */
+
if (len && len->expr_type != EXPR_CONSTANT)
{
+ gfc_namespace *old_ns;
gfc_expr *e;
+
+ old_ns = gfc_current_ns;
+ gfc_current_ns = gfc_get_namespace (NULL, 0);
+
e = gfc_copy_expr (len);
gfc_reduce_init_expr (e);
if (e->expr_type == EXPR_CONSTANT)
@@ -3254,10 +3262,12 @@ done:
}
else
gfc_free_expr (e);
- cl->length = len;
+
+ gfc_free_namespace (gfc_current_ns);
+ gfc_current_ns = old_ns;
}
- else
- cl->length = len;
+
+ cl->length = len;
}
ts->u.cl = cl;