Fortran] PR91586 Fix ICE on invalid code with CLASS
authorTobias Burnus <tobias@codesourcery.com>
Fri, 18 Oct 2019 12:04:31 +0000 (12:04 +0000)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 18 Oct 2019 12:04:31 +0000 (14:04 +0200)
        gcc/fortran/
        PR fortran/91586
        * class.c (gfc_find_derived_vtab): Return NULL
        instead of deref'ing NULL pointer.

        gcc/testsuite/
        PR fortran/91586
        * gfortran.dg/class_71.f90: New.

From-SVN: r277153

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

index 1dbc890f5dab58e5187892a0f2f65dafd0c7bf61..8a1beeafa01bb9d6d3916551c53f32ae5ed81fba 100644 (file)
@@ -1,3 +1,9 @@
+2019-10-18  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/91586
+       * class.c (gfc_find_derived_vtab): Return NULL
+       instead of deref'ing NULL pointer.
+
 2019-10-15  James Norris  <jnorris@codesourcery.com>
            Tobias Burnus  <tobias@codesourcery.com>
 
index 8a1f43f116c52e92984d6bc79eabcce2e5ed90c6..9117121e5feb8a7060810a35e18ad96b68b4f518 100644 (file)
@@ -2241,6 +2241,9 @@ gfc_find_derived_vtab (gfc_symbol *derived)
   if (!derived->attr.unlimited_polymorphic && derived->attr.is_class)
     derived = gfc_get_derived_super_type (derived);
 
+  if (!derived)
+    return NULL;
+
   /* Find the gsymbol for the module of use associated derived types.  */
   if ((derived->attr.use_assoc || derived->attr.used_in_submodule)
        && !derived->attr.vtype && !derived->attr.is_class)
index b783c8dede37411a449dd488aa43b62c529620f3..4e817eb13715dec813bb393d59852a5c68ca622d 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-18  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/91586
+       * gfortran.dg/class_71.f90: New.
+
 2019-10-18  Georg-Johann Lay  <avr@gjlay.de>
 
        Fix some fallout for small targets.
diff --git a/gcc/testsuite/gfortran.dg/class_71.f90 b/gcc/testsuite/gfortran.dg/class_71.f90
new file mode 100644 (file)
index 0000000..bc0ffcd
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do compile }
+!
+! PR fortran/91586
+!
+! Contributed by G. Steinmetz
+!
+program p
+   type t
+      class(*), allocatable :: a
+   end type
+   class(t) :: x, y  ! { dg-error "must be dummy, allocatable or pointer" }
+   y = x  ! { dg-error "Nonallocatable variable must not be polymorphic in intrinsic assignment" }
+end