]> gcc.gnu.org Git - gcc.git/commitdiff
PR fortran/93337 - ICE in gfc_dt_upper_string, at fortran/module.c:441
authorHarald Anlauf <anlauf@gmx.de>
Thu, 2 Jul 2020 18:41:51 +0000 (20:41 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Tue, 7 Jul 2020 19:42:00 +0000 (21:42 +0200)
When declaring a polymorphic variable that is not a dummy, allocatable or
pointer, an ICE occurred due to a NULL pointer dereference.  Check for
that situation and punt.

gcc/fortran/
PR fortran/93337
* class.c (gfc_find_derived_vtab): Punt if name is not set.

(cherry picked from commit d9fb6f2b4f1321b059807ff6073156f07d9d376b)

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

index 84314a089c3ac3f86eef9b850099fb968a6899bd..ab3df62170a90c5e1c42b834f83b608933abe087 100644 (file)
@@ -2262,6 +2262,9 @@ gfc_find_derived_vtab (gfc_symbol *derived)
   if (!derived)
     return NULL;
 
+  if (!derived->name)
+    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/gfortran.dg/pr93337.f90 b/gcc/testsuite/gfortran.dg/pr93337.f90
new file mode 100644 (file)
index 0000000..5cfb929
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! PR fortran/93337 - ICE in gfc_dt_upper_string, at fortran/module.c:441
+
+program p
+  type t
+     character(:), allocatable :: a
+  end type t
+  class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+  x = x         ! { dg-error "must not be polymorphic in intrinsic assignment" }
+end
This page took 0.089799 seconds and 5 git commands to generate.