From: Steven G. Kargl Date: Thu, 27 Oct 2016 03:08:13 +0000 (+0000) Subject: re PR fortran/78092 (ICE when calling SIZEOF on CLASS(*) entry) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe14572b1ae8dc408645a0c4ce1d043d44acece6;p=gcc.git re PR fortran/78092 (ICE when calling SIZEOF on CLASS(*) entry) 2016-10-26 Steven G. Kargl PR fortran/78092 * trans-intrinsic.c (gfc_conv_intrinsic_sizeof): Fix reference to an array element of type CLASS. 2016-10-26 Steven G. Kargl PR fortran/78092 * gfortran.dg/pr78092.f90: New test. From-SVN: r241610 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index bae08b8c8ac..a4bfb0a14f0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-10-26 Steven G. Kargl + + PR fortran/78092 + * trans-intrinsic.c (gfc_conv_intrinsic_sizeof): Fix reference to an + array element of type CLASS. + 2016-10-26 Paul Thomas PR fortran/78108 diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 2911d642e32..463bb58ef93 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -6708,7 +6708,9 @@ gfc_conv_intrinsic_sizeof (gfc_se *se, gfc_expr *expr) TREE_OPERAND (argse.expr, 0), 0))) || GFC_DECL_CLASS (TREE_OPERAND (argse.expr, 0))))) byte_size = gfc_class_vtab_size_get (TREE_OPERAND (argse.expr, 0)); - else if (arg->rank > 0) + else if (arg->rank > 0 + || (arg->rank == 0 + && arg->ref && arg->ref->type == REF_COMPONENT)) /* The scalarizer added an additional temp. To get the class' vptr one has to look at the original backend_decl. */ byte_size = gfc_class_vtab_size_get ( diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8e3e49f3cbb..ac9901b328c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-26 Steven G. Kargl + + PR fortran/78092 + * gfortran.dg/pr78092.f90: New test. + 2016-10-26 Kelvin Nilsen PR target/78056 diff --git a/gcc/testsuite/gfortran.dg/pr78092.f90 b/gcc/testsuite/gfortran.dg/pr78092.f90 new file mode 100644 index 00000000000..ba615d14c9a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78092.f90 @@ -0,0 +1,21 @@ +! { dg-do run } +program test_stuff + + implicit none + + integer :: ivar1(2,3), ivar2 + + ivar1 = 6 + call poly_sizeof(ivar1, ivar2) + + if (ivar2 /= 4) call abort + + contains + + subroutine poly_sizeof(arg1,arg2) + class(*), intent(in) :: arg1(:,:) + integer, intent(out) :: arg2 + arg2 = sizeof(arg1(1,1)) + end subroutine + +end program test_stuff