]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran] PR91586 Fix ICE on invalid code with CLASS
authorTobias Burnus <tobias@codesourcery.com>
Fri, 18 Oct 2019 12:38:26 +0000 (12:38 +0000)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 18 Oct 2019 12:38:26 +0000 (14:38 +0200)
        gcc/fortran/
        Backport from mainline
        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.

        gcc/testsuite/
        Backport from mainline
        2019-10-18  Tobias Burnus  <tobias@codesourcery.com>

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

From-SVN: r277154

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

index 66ff7f143fe836eb68c9f3a1ef15049edb44695c..eb84a154d2793eca0ede8c77733c86990306721f 100644 (file)
@@ -1,3 +1,12 @@
+2019-10-18  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backport from mainline
+       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-17  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/83113
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 4de50acd4824a0351bbd195ee7b600b53f703670..b429ed3c93e46ee99429c59ed65322b8b801c911 100644 (file)
@@ -1,3 +1,11 @@
+2019-10-18  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backport from mainline
+       2019-10-18  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/91586
+       * gfortran.dg/class_71.f90: New.
+
 2019-10-17  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/83113
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