From 58864d1c7a4f6ae4642c6d8fd93b52b7586893ac Mon Sep 17 00:00:00 2001 From: Louis Krupp Date: Tue, 6 Oct 2015 23:47:18 +0000 Subject: [PATCH] [multiple changes] 2015-10-06 Louis Krupp PR fortran/65766 * resolve.c (gfc_resolve_substring_charlen): For derived type, use typespec of string component when resolving substring length. 2015-10-06 Louis Krupp PR fortran/65766 * gfortran.dg/substr_alloc_string_comp_1.f90: New. From-SVN: r228551 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/resolve.c | 15 ++++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f44d66230f0..4dba1deac9e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-10-06 Louis Krupp + PR fortran/65766 + * resolve.c (gfc_resolve_substring_charlen): For derived type, + use typespec of string component when resolving substring length. + 2015-10-04 Mikael Morin * match.c (gfc_match_common): Remove dead variable old_blank_common. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index e75c2930228..50b5c1d2a33 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -4543,10 +4543,15 @@ gfc_resolve_substring_charlen (gfc_expr *e) { gfc_ref *char_ref; gfc_expr *start, *end; + gfc_typespec *ts = NULL; for (char_ref = e->ref; char_ref; char_ref = char_ref->next) - if (char_ref->type == REF_SUBSTRING) - break; + { + if (char_ref->type == REF_SUBSTRING) + break; + if (char_ref->type == REF_COMPONENT) + ts = &char_ref->u.c.component->ts; + } if (!char_ref) return; @@ -4576,7 +4581,11 @@ gfc_resolve_substring_charlen (gfc_expr *e) if (char_ref->u.ss.end) end = gfc_copy_expr (char_ref->u.ss.end); else if (e->expr_type == EXPR_VARIABLE) - end = gfc_copy_expr (e->symtree->n.sym->ts.u.cl->length); + { + if (!ts) + ts = &e->symtree->n.sym->ts; + end = gfc_copy_expr (ts->u.cl->length); + } else end = NULL; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fbae9240173..4ec4743eb48 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -2,6 +2,11 @@ * gcc.target/aarch64/get_lane_f16_1.c: New test. +2015-10-06 Louis Krupp + + PR fortran/65766 + * gfortran.dg/substr_alloc_string_comp_1.f90: New. + 2015-10-06 Marek Polacek PR c++/67863 -- 2.30.2