re PR fortran/78092 (ICE when calling SIZEOF on CLASS(*) entry)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 27 Oct 2016 03:08:13 +0000 (03:08 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 27 Oct 2016 03:08:13 +0000 (03:08 +0000)
2016-10-26  Steven G. Kargl <kargl@gcc.gnu.org>

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 <kargl@gcc.gnu.org>

PR fortran/78092
* gfortran.dg/pr78092.f90: New test.

From-SVN: r241610

gcc/fortran/ChangeLog
gcc/fortran/trans-intrinsic.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr78092.f90 [new file with mode: 0644]

index bae08b8c8ac568b4fb72c1994ac324afef439aff..a4bfb0a14f0c9e46aa2eadd45a703893e36e3b8f 100644 (file)
@@ -1,3 +1,9 @@
+2016-10-26  Steven G. Kargl <kargl@gcc.gnu.org>
+
+       PR fortran/78092
+       * trans-intrinsic.c (gfc_conv_intrinsic_sizeof):  Fix reference to an
+       array element of type CLASS.
+
 2016-10-26  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/78108
index 2911d642e32c459191aa4d7e38de8819d5f7e3b0..463bb58ef939ec349825a533d18bd240242795eb 100644 (file)
@@ -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 (
index 8e3e49f3cbb4cbca2ec8f17f2f129d3c59603afa..ac9901b328c781aac1484adb749a8d744c23ab49 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-26  Steven G. Kargl <kargl@gcc.gnu.org>
+
+       PR fortran/78092
+       * gfortran.dg/pr78092.f90: New test.
+
 2016-10-26  Kelvin Nilsen  <kelvin@gcc.gnu.org>
 
        PR target/78056
diff --git a/gcc/testsuite/gfortran.dg/pr78092.f90 b/gcc/testsuite/gfortran.dg/pr78092.f90
new file mode 100644 (file)
index 0000000..ba615d1
--- /dev/null
@@ -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