PR fortran/95106 - truncation of long symbol names with EQUIVALENCE
authorHarald Anlauf <anlauf@gmx.de>
Sun, 24 May 2020 19:35:04 +0000 (21:35 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Sun, 24 May 2020 19:35:04 +0000 (21:35 +0200)
For long module names, the generated name-mangled symbol was
truncated, leading to bogus warnings about COMMON block
mismatches.  Provide sufficiently large temporaries.

gcc/fortran/

2020-05-24  Harald Anlauf  <anlauf@gmx.de>

PR fortran/95106
* trans-common.c (gfc_sym_mangled_common_id): Enlarge temporaries
for name-mangling.

gcc/testsuite/

2020-05-24  Harald Anlauf  <anlauf@gmx.de>

PR fortran/95106
* gfortran.dg/equiv_11.f90: New test.

gcc/fortran/ChangeLog
gcc/fortran/trans-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/equiv_11.f90 [new file with mode: 0644]

index 55d5dae3cf538a774dda913c716fb654220285b9..7ddc2b81945da9c483d7d830a82ed7dd6f97a003 100644 (file)
@@ -1,3 +1,9 @@
+2020-05-24  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/95106
+       * trans-common.c (gfc_sym_mangled_common_id): Enlarge temporaries
+       for name-mangling.
+
 2020-05-23  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR libfortran/95191
index bf163bc4f52e7fec22d49804ed9fbbb5634ba8b0..3775a8bea747ee3ac62d2b71a0a3ea939bd6c7d8 100644 (file)
@@ -242,8 +242,9 @@ static tree
 gfc_sym_mangled_common_id (gfc_common_head *com)
 {
   int has_underscore;
-  char mangled_name[GFC_MAX_MANGLED_SYMBOL_LEN + 1];
-  char name[GFC_MAX_SYMBOL_LEN + 1];
+  /* Provide sufficient space to hold "symbol.eq.1234567890__".  */
+  char mangled_name[GFC_MAX_MANGLED_SYMBOL_LEN + 1 + 16];
+  char name[GFC_MAX_SYMBOL_LEN + 1 + 16];
 
   /* Get the name out of the common block pointer.  */
   strcpy (name, com->name);
index 80fd33dac18dbfdc79d2b0ce365fc4242ecb0fc1..2710d2ee49002d06152380fa4e29667ead2f8a23 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-24  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/95106
+       * gfortran.dg/equiv_11.f90: New test.
+
 2020-05-23  Patrick Palka  <ppalka@redhat.com>
 
        PR c++/94038
diff --git a/gcc/testsuite/gfortran.dg/equiv_11.f90 b/gcc/testsuite/gfortran.dg/equiv_11.f90
new file mode 100644 (file)
index 0000000..0f4a1ab
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-options "-fsecond-underscore" }
+! PR fortran/95106
+
+module m2345678901234567890123456789012345678901234567890123456789_123
+  implicit none
+  real :: a(4), u(3,2)
+  real :: b(4), v(4,2)
+  equivalence (a(1),u(1,1)), (b(1),v(1,1))
+end
+! { dg-final { scan-assembler {m2345678901234567890123456789012345678901234567890123456789_123.eq.0__} } }
+! { dg-final { scan-assembler {m2345678901234567890123456789012345678901234567890123456789_123.eq.1__} } }