aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/resolve.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2017-11-05 12:38:42 +0000
committerPaul Thomas <pault@gcc.gnu.org>2017-11-05 12:38:42 +0000
commitaea5e9327a49bc73878a547d490bb32ac31df03e (patch)
tree428d69f0ccf3b22d6da4975c720054a5586d124f /gcc/fortran/resolve.c
parentba89e5d5a7c35ff158e749b503c017921a9dbcbc (diff)
downloadgcc-aea5e9327a49bc73878a547d490bb32ac31df03e.zip
gcc-aea5e9327a49bc73878a547d490bb32ac31df03e.tar.gz
gcc-aea5e9327a49bc73878a547d490bb32ac31df03e.tar.bz2
re PR fortran/81447 ([7/8] gfortran fails to recognize the exact dynamic type of a polymorphic entity that was allocated in a external procedure)
2017-11-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/81447 PR fortran/82783 * resolve.c (resolve_component): There is no need to resolve the components of a use associated vtype. (resolve_fl_derived): Unconditionally generate a vtable for any module derived type, as long as the standard is F2003 or later and it is not a vtype or a PDT template. 2017-11-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/81447 * gfortran.dg/class_65.f90: New test. * gfortran.dg/alloc_comp_basics_1.f90: Increase builtin_free count from 18 to 21. * gfortran.dg/allocatable_scalar_9.f90: Increase builtin_free count from 32 to 54. * gfortran.dg/auto_dealloc_1.f90: Increase builtin_free count from 4 to 10. * gfortran.dg/coarray_lib_realloc_1.f90: Increase builtin_free count from 3 to 6. Likewise _gfortran_caf_deregister from 2 to 3, builtin_malloc from 1 to 4 and builtin_memcpy|= MEM from 2 to 5. * gfortran.dg/finalize_28.f90: Increase builtin_free count from 3 to 6. * gfortran.dg/move_alloc_15.f90: Increase builtin_free and builtin_malloc counts from 11 to 14. * gfortran.dg/typebound_proc_27.f03: Increase builtin_free count from 7 to 10. Likewise builtin_malloc from 12 to 15. From-SVN: r254427
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r--gcc/fortran/resolve.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 40c1cd3..50b4b49 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -13496,6 +13496,9 @@ resolve_component (gfc_component *c, gfc_symbol *sym)
if (c->attr.artificial)
return true;
+ if (sym->attr.vtype && sym->attr.use_assoc)
+ return true;
+
/* F2008, C442. */
if ((!sym->attr.is_class || c != sym->components)
&& c->attr.codimension
@@ -14075,6 +14078,20 @@ resolve_fl_derived (gfc_symbol *sym)
if (!resolve_typebound_procedures (sym))
return false;
+ /* Generate module vtables subject to their accessibility and their not
+ being vtables or pdt templates. If this is not done class declarations
+ in external procedures wind up with their own version and so SELECT TYPE
+ fails because the vptrs do not have the same address. */
+ if (gfc_option.allow_std & GFC_STD_F2003
+ && sym->ns->proc_name
+ && sym->ns->proc_name->attr.flavor == FL_MODULE
+ && sym->attr.access != ACCESS_PRIVATE
+ && !(sym->attr.use_assoc || sym->attr.vtype || sym->attr.pdt_template))
+ {
+ gfc_symbol *vtab = gfc_find_derived_vtab (sym);
+ gfc_set_sym_referenced (vtab);
+ }
+
return true;
}
@@ -15943,7 +15960,7 @@ resolve_equivalence (gfc_equiv *eq)
{
gfc_use_rename *r;
for (r = sym->ns->use_stmts->rename; r; r = r->next)
- if (strcmp(r->use_name, sym->name) == 0) saw_sym = true;
+ if (strcmp(r->use_name, sym->name) == 0) saw_sym = true;
}
else
saw_sym = true;