| Submitter | Tobias Burnus |
|---|---|
| Date | May 15, 2012, 10:26 a.m. |
| Message ID | <4FB22F6F.8010000@net-b.de> |
| Download | mbox | patch |
| Permalink | /patch/159287/ |
| State | New |
| Headers | show |
Comments
*ping* On Tue, 15 May 2012 12:26, Tobias Burnus wrote: > A rather simple patch. > > Build and regtested on x86-64-linux. > OK for the trunk? > > I think that is the last patch required for commonly used code. > Remaining are issues with array constructors and concatenations - and, > of course, deferred-length components. > > Tobias
*ping* On 20 May 2012 10:34, Tobias Burnus wrote: > *ping* > > On Tue, 15 May 2012 12:26, Tobias Burnus wrote: >> A rather simple patch. >> >> Build and regtested on x86-64-linux. >> OK for the trunk? >> >> I think that is the last patch required for commonly used code. >> Remaining are issues with array constructors and concatenations - >> and, of course, deferred-length components. >> >> Tobias > >
On Wed, May 23, 2012 at 9:49 PM, Tobias Burnus <burnus@net-b.de> wrote: > *ping* > > On 20 May 2012 10:34, Tobias Burnus wrote: >> >> *ping* >> >> On Tue, 15 May 2012 12:26, Tobias Burnus wrote: >>> >>> A rather simple patch. >>> >>> Build and regtested on x86-64-linux. >>> OK for the trunk? Looks obvious to me :-) Ciao! Steven
Patch
2012-05-15 Tobias Burnus <burnus@net-b.de> PR fortran/51055 PR fortran/45170 * match.c (gfc_match_allocate): Set length_from_typespec for characters. * resolve.c (resolve_charlen): If set, don't check whether the len is a specification expression. 2012-05-15 Tobias Burnus <burnus@net-b.de> PR fortran/51055 PR fortran/45170 * gfortran.dg/allocate_with_typespec_6.f90: New. diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 3d11918..93d7fab 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -3466,6 +3466,9 @@ gfc_match_allocate (void) "type parameter", &old_locus); goto cleanup; } + + if (ts.type == BT_CHARACTER) + ts.u.cl->length_from_typespec = true; } else { diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 9814c14..6fd2d97 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -9945,12 +9945,24 @@ resolve_charlen (gfc_charlen *cl) cl->resolved = 1; - specification_expr = 1; - if (resolve_index_expr (cl->length) == FAILURE) + if (cl->length_from_typespec) { - specification_expr = 0; - return FAILURE; + if (gfc_resolve_expr (cl->length) == FAILURE) + return FAILURE; + + if (gfc_simplify_expr (cl->length, 0) == FAILURE) + return FAILURE; + } + else + { + specification_expr = 1; + + if (resolve_index_expr (cl->length) == FAILURE) + { + specification_expr = 0; + return FAILURE; + } } /* "If the character length parameter value evaluates to a negative --- /dev/null 2012-05-14 08:15:48.907781309 +0200 +++ gcc/gcc/testsuite/gfortran.dg/allocate_with_typespec_6.f90 2012-05-15 09:50:53.000000000 +0200 @@ -0,0 +1,17 @@ +! { dg-do compile } +! +! PR fortran/51055 +! PR fortran/45170 comment 14 +! +! Contributed by Juha Ruokolainen +! and Hans-Werner Boschmann +! +! gfortran was before checking whether the length +! was a specification expression. +! + +program a + character(len=:), allocatable :: s + integer :: i=10 + allocate(character(len=i)::s) +end program a