[gcc/devel/omp/gcc-9] backport: re PR fortran/90937 (ICE: in gfc_get_symbol_decl, at fortran/trans-decl.c:1538)

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


https://gcc.gnu.org/g:f21857aed5c536e684626eb07df07838776e21ff

commit f21857aed5c536e684626eb07df07838776e21ff
Author: Thomas Koenig <tkoenig@gcc.gnu.org>
Date:   Fri Jun 21 19:28:54 2019 +0000

    backport: re PR fortran/90937 (ICE: in gfc_get_symbol_decl, at fortran/trans-decl.c:1538)
    
    2019-06-21  Thomas Koenig  <tkoenig@gcc.gnu.org>
    
    	Backport from trunk
    	PR fortran/90937
    	* trans-types.c (get_formal_from_actual_arglist): Get symbol from
    	current namespace so it will be freed later.  If symbol is of type
    	character, get an empty character length.
    
    2019-06-21  Thomas Koenig  <tkoenig@gcc.gnu.org>
    
    	Backport from trunk
    	PR fortran/90937
    	* gfortran.dg/external_procedure_4.f90: New test.
    
    From-SVN: r272564

Diff:
---
 gcc/fortran/ChangeLog                              | 10 +++++++++-
 gcc/fortran/trans-types.c                          |  6 +++++-
 gcc/testsuite/ChangeLog                            |  8 ++++++++
 gcc/testsuite/gfortran.dg/external_procedure_4.f90 | 19 +++++++++++++++++++
 4 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 35d3091..4e5e263 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2019-06-21  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+	Backport from trunk
+	PR fortran/90937
+	* trans-types.c (get_formal_from_actual_arglist): Get symbol from
+	current namespace so it will be freed later.  If symbol is of type
+	character, get an empty character length.
+
 2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
 	Backport from mainline
@@ -9,7 +17,7 @@
 	Backport from mainline
 	PR fortran/90002
 	* array.c (gfc_free_array_spec): When freeing an array-spec, avoid
-	an ICE for assumed-shape coarrays 
+	an ICE for assumed-shape coarrays.
 
 2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 17dc12f..d3b61e7 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2997,7 +2997,7 @@ get_formal_from_actual_arglist (gfc_symbol *sym, gfc_actual_arglist *actual_args
       if (a->expr)
 	{
 	  snprintf (name, GFC_MAX_SYMBOL_LEN, "_formal_%d", var_num ++);
-	  gfc_get_symbol (name, NULL, &s);
+	  gfc_get_symbol (name, gfc_current_ns, &s);
 	  if (a->expr->ts.type == BT_PROCEDURE)
 	    {
 	      s->attr.flavor = FL_PROCEDURE;
@@ -3005,6 +3005,10 @@ get_formal_from_actual_arglist (gfc_symbol *sym, gfc_actual_arglist *actual_args
 	  else
 	    {
 	      s->ts = a->expr->ts;
+
+	      if (s->ts.type == BT_CHARACTER)
+		  s->ts.u.cl = gfc_get_charlen ();
+
 	      s->ts.deferred = 0;
 	      s->ts.is_iso_c = 0;
 	      s->ts.is_c_interop = 0;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7ad4fa2..ad21677 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2019-06-21  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+	Backport from trunk
+	PR fortran/90937
+	* trans-types.c (get_formal_from_actual_arglist): Get symbol from
+	current namespace so it will be freed later.  If symbol is of type
+	character, get an empty character length.
+
 2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
 	Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/external_procedure_4.f90 b/gcc/testsuite/gfortran.dg/external_procedure_4.f90
new file mode 100644
index 0000000..403f173
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/external_procedure_4.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! PR fortran/90937 - this used to cause an ICE.
+! Original test case by Toon Moene.
+subroutine lfidiff
+
+   implicit none
+
+   contains 
+
+      subroutine grlfi(cdnom)
+
+         character(len=*) cdnom(:)
+         character(len=len(cdnom)) clnoma
+
+         call lficas(clnoma)
+
+      end subroutine grlfi
+
+end subroutine lfidiff



More information about the Gcc-cvs mailing list