[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 f44d66230f0020728dc89ce6186e7854fea42c89..4dba1deac9e2ca9cefefff22708d33593ec590eb 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 e75c29302288effc7f4017a42a653401130b8ece..50b5c1d2a330cab14ec9557f850bb6b4b2336733 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 fbae9240173a3f4e38ab7feaa71bc5e2dd29ef82..4ec4743eb48f308cd141da0fc1e6f4807135d198 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