aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/class.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2019-02-21 18:01:41 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2019-02-21 18:01:41 +0000
commit9e6644c6fd3c9cf9f6a2fc6315052c953ab363cf (patch)
tree3de186d92dc63e6ad443f16ca94c716d68fc4a25 /gcc/fortran/class.c
parenteb74a883e812fc1a05fbf9cfa572043c4ee5af39 (diff)
downloadgcc-9e6644c6fd3c9cf9f6a2fc6315052c953ab363cf.zip
gcc-9e6644c6fd3c9cf9f6a2fc6315052c953ab363cf.tar.gz
gcc-9e6644c6fd3c9cf9f6a2fc6315052c953ab363cf.tar.bz2
re PR fortran/86119 (Intrinsic len has wrong type if used within select type for a class(*) string)
2019-02-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/86119 * class.c (gfc_get_len_component): Add argument k for kind. If the kind of the resulting expression is not equal to k, convert it. * gfortran.h (gfc_len_component): Adjust prototype. * simplify.c (gfc_simplify_len): Pass kind to gfc_get_len_component. 2019-02-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/86119 * gfortran.dg/warn_conversion_11.f90: New test. From-SVN: r269070
Diffstat (limited to 'gcc/fortran/class.c')
-rw-r--r--gcc/fortran/class.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 6c6139b..bcbe631 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -565,7 +565,7 @@ gfc_intrinsic_hash_value (gfc_typespec *ts)
ref to the _len component. */
gfc_expr *
-gfc_get_len_component (gfc_expr *e)
+gfc_get_len_component (gfc_expr *e, int k)
{
gfc_expr *ptr;
gfc_ref *ref, **last;
@@ -590,6 +590,14 @@ gfc_get_len_component (gfc_expr *e)
}
/* And replace if with a ref to the _len component. */
gfc_add_len_component (ptr);
+ if (k != ptr->ts.kind)
+ {
+ gfc_typespec ts;
+ gfc_clear_ts (&ts);
+ ts.type = BT_INTEGER;
+ ts.kind = k;
+ gfc_convert_type_warn (ptr, &ts, 2, 0);
+ }
return ptr;
}