From: Thomas Koenig Date: Fri, 21 Jun 2019 19:28:54 +0000 (+0000) Subject: backport: re PR fortran/90937 (ICE: in gfc_get_symbol_decl, at fortran/trans-decl... X-Git-Tag: releases/gcc-9.2.0~213 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f21857aed5c536e684626eb07df07838776e21ff;p=thirdparty%2Fgcc.git backport: re PR fortran/90937 (ICE: in gfc_get_symbol_decl, at fortran/trans-decl.c:1538) 2019-06-21 Thomas Koenig 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 Backport from trunk PR fortran/90937 * gfortran.dg/external_procedure_4.f90: New test. From-SVN: r272564 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 35d3091c0a6f..4e5e263bda5a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2019-06-21 Thomas Koenig + + 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 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 diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 17dc12f51f8c..d3b61e78887f 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 7ad4fa2164eb..ad2167761bec 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-06-21 Thomas Koenig + + 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 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 000000000000..403f1732e26d --- /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