From c949ec9c4e88d2ff6dbd5b179abddf3703129577 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 27 May 2020 21:20:24 +0200 Subject: [PATCH] PR fortran/95090 - ICE: identifier overflow For long module name, derive type and component name, the generated name-mangled symbol did not fit into a buffer when coarrays were enabled. Provide sufficiently large temporary. 2020-05-27 Harald Anlauf gcc/fortran/ PR fortran/95090 * iresolve.c (gfc_get_string): Enlarge temporary for name-mangling. gcc/testsuite/ PR fortran/95090 * gfortran.dg/pr95090.f90: New test. --- gcc/fortran/iresolve.c | 3 ++- gcc/testsuite/gfortran.dg/pr95090.f90 | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr95090.f90 diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c index 7ecb6595f59..df4f2265c58 100644 --- a/gcc/fortran/iresolve.c +++ b/gcc/fortran/iresolve.c @@ -47,7 +47,8 @@ along with GCC; see the file COPYING3. If not see const char * gfc_get_string (const char *format, ...) { - char temp_name[128]; + /* Provide sufficient space to hold "_F.caf_token__symbol_MOD_symbol". */ + char temp_name[14 + GFC_MAX_SYMBOL_LEN + 5 + GFC_MAX_SYMBOL_LEN + 1]; const char *str; va_list ap; tree ident; diff --git a/gcc/testsuite/gfortran.dg/pr95090.f90 b/gcc/testsuite/gfortran.dg/pr95090.f90 new file mode 100644 index 00000000000..ec77802ec51 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr95090.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib -fsecond-underscore" } +! PR fortran/95090 - ICE: identifier overflow + +module m2345678901234567890123456789012345678901234567890123456789_123 + type t2345678901234567890123456789012345678901234567890123456789_123 & + (n2345678901234567890123456789012345678901234567890123456789_123) + integer, len :: n2345678901234567890123456789012345678901234567890123456789_123 = 8 + end type + integer :: a2345678901234567890123456789012345678901234567890123456789_123 + integer :: b2345678901234567890123456789012345678901234567890123456789_123(3)[*] + data b2345678901234567890123456789012345678901234567890123456789_123 /1,2,3/ +contains + subroutine s2345678901234567890123456789012345678901234567890123456789_123 + type(t2345678901234567890123456789012345678901234567890123456789_123 & + (n2345678901234567890123456789012345678901234567890123456789_123)) :: & + z2345678901234567890123456789012345678901234567890123456789_123 + end +end -- 2.30.2