[multiple changes]
authorLouis Krupp <louis.krupp@zoho.com>
Tue, 6 Oct 2015 23:47:18 +0000 (23:47 +0000)
committerLouis Krupp <lkrupp@gcc.gnu.org>
Tue, 6 Oct 2015 23:47:18 +0000 (23:47 +0000)
2015-10-06  Louis Krupp <louis.krupp@zoho.com>
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     <louis.krupp@zoho.com>

PR fortran/65766
* gfortran.dg/substr_alloc_string_comp_1.f90: New.

From-SVN: r228551

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog

index f44d662..4dba1de 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-06  Louis Krupp <louis.krupp@zoho.com>
+       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  <mikael@gcc.gnu.org>
 
        * match.c (gfc_match_common): Remove dead variable old_blank_common.
index e75c293..50b5c1d 100644 (file)
@@ -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;
 
index fbae924..4ec4743 100644 (file)
@@ -2,6 +2,11 @@
 
        * gcc.target/aarch64/get_lane_f16_1.c: New test.
 
+2015-10-06  Louis Krupp     <louis.krupp@zoho.com>
+
+       PR fortran/65766
+       * gfortran.dg/substr_alloc_string_comp_1.f90: New.
+
 2015-10-06  Marek Polacek  <polacek@redhat.com>
 
        PR c++/67863