diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2017-02-19 18:27:14 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2017-02-19 18:27:14 +0000 |
commit | dea71ad06f751484f3eb5c52bf12622e4c06b33a (patch) | |
tree | 902eaa7282803c05549571ccaaa973291c2f44a3 /gcc/fortran/resolve.c | |
parent | e0396d770f84acfbbbb2397cd2bc53aa57996550 (diff) | |
download | gcc-dea71ad06f751484f3eb5c52bf12622e4c06b33a.zip gcc-dea71ad06f751484f3eb5c52bf12622e4c06b33a.tar.gz gcc-dea71ad06f751484f3eb5c52bf12622e4c06b33a.tar.bz2 |
re PR fortran/79402 (ICE with submodules: module procedure interface defined in parent module)
2017-02-19 Paul Thomas <pault@gcc.gnu.org>
PR fortran/79402
* resolve.c (fixup_unique_dummy): New function.
(gfc_resolve_expr): Call it for dummy variables with a unique
symtree name.
2017-02-19 Paul Thomas <pault@gcc.gnu.org>
PR fortran/79402
* gfortran.dg/submodule_23.f90: New test.
From-SVN: r245580
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index a5fe231..876f3cd 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -6433,6 +6433,31 @@ gfc_is_expandable_expr (gfc_expr *e) return false; } + +/* Sometimes variables in specification expressions of the result + of module procedures in submodules wind up not being the 'real' + dummy. Find this, if possible, in the namespace of the first + formal argument. */ + +static void +fixup_unique_dummy (gfc_expr *e) +{ + gfc_symtree *st = NULL; + gfc_symbol *s = NULL; + + if (e->symtree->n.sym->ns->proc_name + && e->symtree->n.sym->ns->proc_name->formal) + s = e->symtree->n.sym->ns->proc_name->formal->sym; + + if (s != NULL) + st = gfc_find_symtree (s->ns->sym_root, e->symtree->n.sym->name); + + if (st != NULL + && st->n.sym != NULL + && st->n.sym->attr.dummy) + e->symtree = st; +} + /* Resolve an expression. That is, make sure that types of operands agree with their operators, intrinsic operators are converted to function calls for overloaded types and unresolved function references are resolved. */ @@ -6457,6 +6482,14 @@ gfc_resolve_expr (gfc_expr *e) actual_arg = false; first_actual_arg = false; } + else if (e->symtree != NULL + && *e->symtree->name == '@' + && e->symtree->n.sym->attr.dummy) + { + /* Deal with submodule specification expressions that are not + found to be referenced in module.c(read_cleanup). */ + fixup_unique_dummy (e); + } switch (e->expr_type) { |