diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2011-08-30 15:34:01 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2011-08-30 15:34:01 +0000 |
commit | 505920d6b128de2b78279486a2a1a95e38f5f940 (patch) | |
tree | 571e9966557aae713059987b1bd1f315293784a7 /gcc | |
parent | a728a2ada0698cbd8688d5eb6d88d357ec27eb5b (diff) | |
download | gcc-505920d6b128de2b78279486a2a1a95e38f5f940.zip gcc-505920d6b128de2b78279486a2a1a95e38f5f940.tar.gz gcc-505920d6b128de2b78279486a2a1a95e38f5f940.tar.bz2 |
re PR fortran/45170 ([F2003] allocatable character lengths)
2011-08-30 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/45170
* trans-stmt.c (gfc_trans_allocate): Evaluate the substring.
2011-08-30 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/45170
* gfortran.dg/allocate_with_source_2.f90: New test
From-SVN: r178329
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fortran/trans-stmt.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/allocate_with_source_2.f90 | 21 |
4 files changed, 35 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d47e411..4f906b2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2011-08-30 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/45170 + * trans-stmt.c (gfc_trans_allocate): Evaluate the substring. + 2011-08-29 Janus Weil <janus@gcc.gnu.org> PR fortran/50225 diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index a911a5b..7d8b4e0 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -4783,6 +4783,10 @@ gfc_trans_allocate (gfc_code * code) || code->expr3->expr_type == EXPR_CONSTANT) { gfc_conv_expr (&se_sz, code->expr3); + gfc_add_block_to_block (&se.pre, &se_sz.pre); + se_sz.string_length + = gfc_evaluate_now (se_sz.string_length, &se.pre); + gfc_add_block_to_block (&se.pre, &se_sz.post); memsz = se_sz.string_length; } else if (code->expr3->mold diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ccaf17c..0820eaf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-08-30 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/45170 + * gfortran.dg/allocate_with_source_2.f90: New test + 2011-08-30 Jason Merrill <jason@redhat.com> PR c++/50220 diff --git a/gcc/testsuite/gfortran.dg/allocate_with_source_2.f90 b/gcc/testsuite/gfortran.dg/allocate_with_source_2.f90 new file mode 100644 index 0000000..8e48b22 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_with_source_2.f90 @@ -0,0 +1,21 @@ +! { dg-do run } +! PR 45170 +! A variation of a theme for deferred type parameters. The +! substring reference in the source= portion of the allocate +! was not probably resolved. Testcase is a modified version +! of a program due to Hans-Werner Boschmann <boschmann at tp1 +! dot physik dot uni-siegen dot de> +! +program helloworld + character(:),allocatable::string + real::rnd + call hello(5, string) + if (string /= 'hello' .or. len(string) /= 5) call abort +contains + subroutine hello (n,string) + character(:),allocatable,intent(out)::string + integer,intent(in)::n + character(20)::helloworld="hello world" + allocate(string, source=helloworld(:n)) + end subroutine hello +end program helloworld |