re PR fortran/88047 (ICE in gfc_find_vtab, at fortran/class.c:2843)
authorJanus Weil <janus@gcc.gnu.org>
Tue, 8 Jan 2019 19:29:01 +0000 (20:29 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Tue, 8 Jan 2019 19:29:01 +0000 (20:29 +0100)
2019-01-08  Janus Weil  <janus@gcc.gnu.org>

PR fortran/88047
* class.c (gfc_find_vtab): For polymorphic typespecs, the components of
the class container may not be available (in case of invalid code).

2019-01-08  Janus Weil  <janus@gcc.gnu.org>

PR fortran/88047
* gfortran.dg/class_69.f90: New test case.

From-SVN: r267735

gcc/fortran/ChangeLog
gcc/fortran/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_69.f90 [new file with mode: 0644]

index 73d47da983267a1f95d81cb25242cbb37fc67d0f..f29be83229e1a6a54b51a73822157ca1f1a8a656 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-08  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/88047
+       * class.c (gfc_find_vtab): For polymorphic typespecs, the components of
+       the class container may not be available (in case of invalid code).
+
 2019-01-08  Richard Biener  <rguenther@suse.de>
 
        PR fortran/88611
index 77f0fca9385c7595dbcea870d429902e03720b2d..8809b5b5b6e738e4df75e236c0ce6ebab5955bd6 100644 (file)
@@ -2846,7 +2846,10 @@ gfc_find_vtab (gfc_typespec *ts)
     case BT_DERIVED:
       return gfc_find_derived_vtab (ts->u.derived);
     case BT_CLASS:
-      return gfc_find_derived_vtab (ts->u.derived->components->ts.u.derived);
+      if (ts->u.derived->components && ts->u.derived->components->ts.u.derived)
+       return gfc_find_derived_vtab (ts->u.derived->components->ts.u.derived);
+      else
+       return NULL;
     default:
       return find_intrinsic_vtab (ts);
     }
index 28439297735b9221fa94b9885ffd0f7b7dfb4f1d..2c9fe3255b2d1fb57d0d7ee3ff6173aa7ad7e5d0 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-08  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/88047
+       * gfortran.dg/class_69.f90: New test case.
+
 2019-01-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/88717
diff --git a/gcc/testsuite/gfortran.dg/class_69.f90 b/gcc/testsuite/gfortran.dg/class_69.f90
new file mode 100644 (file)
index 0000000..e45e035
--- /dev/null
@@ -0,0 +1,21 @@
+! { dg-do compile }
+!
+! PR 88047: [9 Regression] ICE in gfc_find_vtab, at fortran/class.c:2843
+!
+! Contributed by G. Steinmetz <gscfq@t-online.de>
+
+subroutine sub_a
+   type t
+   end type
+   class(t) :: x(2)                   ! { dg-error "must be dummy, allocatable or pointer" }
+   class(t), parameter :: a(2) = t()  ! { dg-error "cannot have the PARAMETER attribute" }
+   x = a                              ! { dg-error "Nonallocatable variable must not be polymorphic in intrinsic assignment" }
+end
+
+subroutine sub_b
+   type t
+      integer :: n
+   end type
+   class(t) :: a, x                   ! { dg-error "must be dummy, allocatable or pointer" }
+   x = a                              ! { dg-error "Nonallocatable variable must not be polymorphic in intrinsic assignment" }
+end