aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/misc.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2020-06-30 13:01:36 +0200
committerThomas Koenig <tkoenig@gcc.gnu.org>2020-06-30 13:10:20 +0200
commit5958b926dcc3332aec0a2e34653c4394d2613401 (patch)
treea883a14d091366ae9442362f8ec6d327b0e469de /gcc/fortran/misc.c
parent8dc933c12f489626339b3ba1a8e2dc23eb4de98e (diff)
downloadgcc-5958b926dcc3332aec0a2e34653c4394d2613401.zip
gcc-5958b926dcc3332aec0a2e34653c4394d2613401.tar.gz
gcc-5958b926dcc3332aec0a2e34653c4394d2613401.tar.bz2
Use CHARACTER(kind) string for calculating the type hash.
This regression came about because of a change in the way types are displayed in error messages. The character representation is also used to calculate the hashes for our types, so this patch restores the old behavior if we are indeed calculating a hash. The test case also checks for the specific hash value because changing that would be an ABI change, which we should not be doing unintentionally. gcc/fortran/ChangeLog: 2020-06-30 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/95355 * gfortran.h (gfc_typename): Add optional argument for_hash. * misc.c (gfc_typename): When for_hash is true, just retur CHARACTER(kind). * class.c (gfc_intrinsic_hash_value): Call gfc_typename with for_hash = true.
Diffstat (limited to 'gcc/fortran/misc.c')
-rw-r--r--gcc/fortran/misc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/fortran/misc.c b/gcc/fortran/misc.c
index 46c6277..65bcfa6 100644
--- a/gcc/fortran/misc.c
+++ b/gcc/fortran/misc.c
@@ -122,7 +122,7 @@ gfc_basic_typename (bt type)
the argument list of a single statement. */
const char *
-gfc_typename (gfc_typespec *ts)
+gfc_typename (gfc_typespec *ts, bool for_hash)
{
static char buffer1[GFC_MAX_SYMBOL_LEN + 7]; /* 7 for "TYPE()" + '\0'. */
static char buffer2[GFC_MAX_SYMBOL_LEN + 7];
@@ -149,6 +149,12 @@ gfc_typename (gfc_typespec *ts)
sprintf (buffer, "LOGICAL(%d)", ts->kind);
break;
case BT_CHARACTER:
+ if (for_hash)
+ {
+ sprintf (buffer, "CHARACTER(%d)", ts->kind);
+ break;
+ }
+
if (ts->u.cl && ts->u.cl->length)
length = gfc_mpz_get_hwi (ts->u.cl->length->value.integer);
if (ts->kind == gfc_default_character_kind)