Hi all, attached patch adds an unimplemented message, when a polymorphic coarray object with allocatable/pointer components is declared for coarray mode library. This is just an ad-hoc solution until handling those constructs is implemented. There are already some prs that address ICEs caused by this issue: 77961, 77785.
Bootstrapped and regtests ok on x86_64-linux/F23. May have some fuzz when the patch for polymorphic assign: https://gcc.gnu.org/ml/fortran/2016-10/msg00091.html is not present. The polymorphic assign patch is not necessary for this patch. If no one objects, I will commit tomorrow morning. Regards, Andre -- Andre Vehreschild * Email: vehre ad gmx dot de
Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=caf_unimp.clog gcc/testsuite/ChangeLog: 2016-10-13 Andre Vehreschild <ve...@gcc.gnu.org> * gfortran.dg/coarray_38.f90: Expect error message. gcc/fortran/ChangeLog: 2016-10-13 Andre Vehreschild <ve...@gcc.gnu.org> * resolve.c (resolve_symbol): Add unimplemented message for polymorphic types with allocatable/pointer components and coarray=lib.
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 42e3421..2226227 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -13796,6 +13796,19 @@ resolve_symbol (gfc_symbol *sym) (just like derived type declaration symbols have flavor FL_DERIVED). */ gcc_assert (sym->ts.type != BT_UNION); + /* Coarrayed polymorphic objects with allocatable or pointer components are + yet unsupported for -fcoarray=lib. */ + if (flag_coarray == GFC_FCOARRAY_LIB && sym->ts.type == BT_CLASS + && sym->ts.u.derived && CLASS_DATA (sym) + && CLASS_DATA (sym)->attr.codimension + && (sym->ts.u.derived->attr.alloc_comp + || sym->ts.u.derived->attr.pointer_comp)) + { + gfc_error ("Sorry, allocatable/pointer components in polymorphic (CLASS) " + "type coarrays at %L are unsupported", &sym->declared_at); + return; + } + if (sym->attr.artificial) return; diff --git a/gcc/testsuite/gfortran.dg/coarray_38.f90 b/gcc/testsuite/gfortran.dg/coarray_38.f90 index 31155c5..c8011d4 100644 --- a/gcc/testsuite/gfortran.dg/coarray_38.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_38.f90 @@ -71,7 +71,7 @@ end type t type t2 class(t), allocatable :: caf2[:] end type t2 -class(t), allocatable :: caf[:] +class(t), allocatable :: caf[:] ! { dg-error "Sorry, allocatable/pointer components in polymorphic" } type(t) :: x type(t2) :: y