[9/10/11,Regression] PR fortran/93337 - ICE in gfc_dt_upper_string, at fortran/module.c:441

Message ID trinity-b70dd10d-5b89-4c6f-83c9-2d3abf732f70-1593116366627@3c-app-gmx-bs75
State New
Headers show
Series
  • [9/10/11,Regression] PR fortran/93337 - ICE in gfc_dt_upper_string, at fortran/module.c:441
Related show

Commit Message

Harald Anlauf June 25, 2020, 8:19 p.m.
This PR is due to a plain NULL pointer that needs to get caught in the right place.

Regtested on x86_64-pc-linux-gnu.

OK for master / backports where applicable?

Thanks,
Harald


PR fortran/93337 - ICE in gfc_dt_upper_string, at fortran/module.c:441

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.

Comments

Harald Anlauf June 29, 2020, 7:02 p.m. | #1
Early ping (might make it into 10.2.1).

> This PR is due to a plain NULL pointer that needs to get caught in the right place.

>

> Regtested on x86_64-pc-linux-gnu.

>

> OK for master / backports where applicable?

>

> Thanks,

> Harald

>

>

> PR fortran/93337 - ICE in gfc_dt_upper_string, at fortran/module.c:441

>

> 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.

>

>


Thanks,
Harald

Patch

diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 2b760efe8d7..48f81d89a74 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -2277,6 +2277,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
index 00000000000..5cfb9297990
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93337.f90
@@ -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