[gcc/devel/omp/gcc-9] Fortran] PR91586 Fix ICE on invalid code with CLASS

Tobias Burnus burnus@gcc.gnu.org
Thu Mar 5 14:10:00 GMT 2020


https://gcc.gnu.org/g:412f7637d16c6e791e2787fd667ff4a8dcafcadb

commit 412f7637d16c6e791e2787fd667ff4a8dcafcadb
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Fri Oct 18 12:38:26 2019 +0000

    Fortran] PR91586 Fix ICE on invalid code with CLASS
    
            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

Diff:
---
 gcc/fortran/ChangeLog                  |  9 +++++++++
 gcc/fortran/class.c                    |  3 +++
 gcc/testsuite/ChangeLog                |  8 ++++++++
 gcc/testsuite/gfortran.dg/class_71.f90 | 13 +++++++++++++
 4 files changed, 33 insertions(+)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 66ff7f1..eb84a15 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 8a1f43f..9117121 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4de50ac..b429ed3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..bc0ffcd
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/class_71.f90
@@ -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



More information about the Gcc-cvs mailing list