[PATCH] Remove dead Fortran function.

2021-11-09 Thread Martin Liška

Hello.

The function was introduced in 2009 in 
g:cf2b3c22a2cbd7f50db530ca9d2b14c70ba0359d
and has never been used since that.

Ready to be installed?
Thanks,
Martin

gcc/fortran/ChangeLog:

* symbol.c (gfc_get_ultimate_derived_super_type): Remove.
---
 gcc/fortran/symbol.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 8c9a1d00ce0..173c36f51bc 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -5106,23 +5106,6 @@ gfc_get_derived_super_type (gfc_symbol* derived)
 }
 
 
-/* Get the ultimate super-type of a given derived type.  */

-
-static gfc_symbol*
-gfc_get_ultimate_derived_super_type (gfc_symbol* derived)
-{
-  if (!derived->attr.extension)
-return NULL;
-
-  derived = gfc_get_derived_super_type (derived);
-
-  if (derived->attr.extension)
-return gfc_get_ultimate_derived_super_type (derived);
-  else
-return derived;
-}
-
-
 /* Check if a derived type t2 is an extension of (or equal to) a type t1.  */
 
 bool

--
2.33.1



Re: [PATCH] Remove dead Fortran function.

2021-11-09 Thread Jeff Law via Fortran




On 11/9/2021 6:59 AM, Martin Liška wrote:

Hello.

The function was introduced in 2009 in 
g:cf2b3c22a2cbd7f50db530ca9d2b14c70ba0359d

and has never been used since that.

Ready to be installed?
Thanks,
Martin

gcc/fortran/ChangeLog:

* symbol.c (gfc_get_ultimate_derived_super_type): Remove.

OK
jeff



[PATCH] PR fortran/103217 & 103218 - ICEs during simplification after r12-4967-gbcf3728abe848888

2021-11-09 Thread Harald Anlauf via Fortran
Dear all,

I'd like to commit the attached patch as obvious within the next 24 hours
unless anybody objects, or earlier if there is positive feedback.

The patch only fixes three obvious NULL pointer dereferences that were
latent before the referenced commit and exhibited in the testcases,
see PRs.

The submitted testcases in the PRs hint at unimplemented parts of the
F2018 standard in gfortran.  I consider it unlikely that these parts are
written before 12-release, so fixing the ICE is something that can be
done now.  After that, either the regression marker can be removed from
the PRs, or they are closed and the remaining issues moved to a new PR.

Regtested on x86_64-pc-linux-gnu.  Comments welcome.

Thanks,
Harald

From a40cbf2b28db7824740ff1cff3eaffcd768fe456 Mon Sep 17 00:00:00 2001
From: Harald Anlauf 
Date: Tue, 9 Nov 2021 21:02:44 +0100
Subject: [PATCH] Fortran: avoid NULL pointer dereferences

gcc/fortran/ChangeLog:

	PR fortran/103137
	PR fortran/103138
	* check.c (gfc_check_shape): Avoid NULL pointer dereference on
	missing ref.
	* simplify.c (gfc_simplify_cshift): Avoid NULL pointer dereference
	when shape not set.
	(gfc_simplify_transpose): Likewise.
---
 gcc/fortran/check.c| 3 +++
 gcc/fortran/simplify.c | 6 ++
 2 files changed, 9 insertions(+)

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 15772009af4..ffa07b510cd 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -5096,6 +5096,9 @@ gfc_check_shape (gfc_expr *source, gfc_expr *kind)
   if (source->rank == 0 || source->expr_type != EXPR_VARIABLE)
 return true;

+  if (source->ref == NULL)
+return false;
+
   ar = gfc_find_array_ref (source);

   if (ar->as && ar->as->type == AS_ASSUMED_SIZE && ar->type == AR_FULL)
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index d675f2c3aef..6a6b3fbd037 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -2109,6 +2109,9 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim)
   else
 which = 0;

+  if (array->shape == NULL)
+return NULL;
+
   gfc_array_size (array, &size);
   arraysize = mpz_get_ui (size);
   mpz_clear (size);
@@ -8174,6 +8177,9 @@ gfc_simplify_transpose (gfc_expr *matrix)

   gcc_assert (matrix->rank == 2);

+  if (matrix->shape == NULL)
+return NULL;
+
   result = gfc_get_array_expr (matrix->ts.type, matrix->ts.kind,
 			   &matrix->where);
   result->rank = 2;
--
2.26.2



Re: [PATCH] PR fortran/103217 & 103218 - ICEs during simplification after r12-4967-gbcf3728abe848888

2021-11-09 Thread Thomas Koenig via Fortran



Hi Harald,


I'd like to commit the attached patch as obvious within the next 24 hours
unless anybody objects, or earlier if there is positive feedback.


OK with a ChangeLog entry and the correct PR numbers (I believe
they are 103137 and 103138) :-)

Best regards

Thomas