diff options
author | Tobias Burnus <burnus@net-b.de> | 2012-05-23 22:35:30 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2012-05-23 22:35:30 +0200 |
commit | 239b48db1b238cf5395570604ca4400e74025ab4 (patch) | |
tree | a7d3d8d07d0cdf98767cf2fe01f82ab79c4d7140 | |
parent | 2e74510357a26f3ec3f80d5c770437ca3666d92a (diff) | |
download | gcc-239b48db1b238cf5395570604ca4400e74025ab4.zip gcc-239b48db1b238cf5395570604ca4400e74025ab4.tar.gz gcc-239b48db1b238cf5395570604ca4400e74025ab4.tar.bz2 |
re PR fortran/51055 (deferred length character allocation: allocate(character(len=i)::s) rejected)
2012-05-23 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-23 Tobias Burnus <burnus@net-b.de>
PR fortran/51055
PR fortran/45170
* gfortran.dg/allocate_with_typespec_6.f90: New.
From-SVN: r187811
-rw-r--r-- | gcc/fortran/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fortran/match.c | 3 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/allocate_with_typespec_6.f90 | 17 |
5 files changed, 51 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 38bff78..fe13cc5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2012-05-23 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-22 Tobias Burnus <burnus@net-b.de> PR fortran/53389 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..a56d3f7 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 35dd366..f337a29 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-05-23 Tobias Burnus <burnus@net-b.de> + + PR fortran/51055 + PR fortran/45170 + * gfortran.dg/allocate_with_typespec_6.f90: New. + 2012-05-23 Paolo Carlini <paolo.carlini@oracle.com> PR c++/29185 diff --git a/gcc/testsuite/gfortran.dg/allocate_with_typespec_6.f90 b/gcc/testsuite/gfortran.dg/allocate_with_typespec_6.f90 new file mode 100644 index 0000000..cd13076 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_with_typespec_6.f90 @@ -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 |