This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran, committed] fix PR 58749
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 04 Jun 2015 20:57:36 +0200
- Subject: [patch, fortran, committed] fix PR 58749
- Authentication-results: sourceware.org; auth=none
Hello world,
the attached patch fixes the PR by adding a charlen to the
function expression of adjustl and adjustr. Committed
as obvious after regression-testing.
Regards
Thomas
2015-06-04 Thomas Koenig <tkoenig@netcologne.de>
PR fortran/58749
* iresolve.c (gfc_resolve_adjustl): If string has a charlen,
copy it to the function.
(gfc_resolve_adjustr): Likewise.
2015-06-04 Thomas Koenig <tkoenig@netcologne.de>
PR fortran/58749
* gfortran.dg/adjustl_1.f90: New test.
Index: iresolve.c
===================================================================
--- iresolve.c (Revision 223876)
+++ iresolve.c (Arbeitskopie)
@@ -218,6 +218,9 @@ gfc_resolve_adjustl (gfc_expr *f, gfc_expr *string
{
f->ts.type = BT_CHARACTER;
f->ts.kind = string->ts.kind;
+ if (string->ts.u.cl)
+ f->ts.u.cl = gfc_new_charlen (gfc_current_ns, string->ts.u.cl);
+
f->value.function.name = gfc_get_string ("__adjustl_s%d", f->ts.kind);
}
@@ -227,6 +230,9 @@ gfc_resolve_adjustr (gfc_expr *f, gfc_expr *string
{
f->ts.type = BT_CHARACTER;
f->ts.kind = string->ts.kind;
+ if (string->ts.u.cl)
+ f->ts.u.cl = gfc_new_charlen (gfc_current_ns, string->ts.u.cl);
+
f->value.function.name = gfc_get_string ("__adjustr_s%d", f->ts.kind);
}
! { dg-do run }
! PR 52749 - this used to ICE.
! Original test case by Stefan Mauerberger.
PROGRAM test
character(len=10) :: u
WRITE(unit=u,fmt='(3A)') PACK(ADJUSTL([" a", " b"]), [.TRUE., .FALSE.])
if (u .ne. 'a ') call abort
END PROGRAM test