diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2016-07-05 14:06:22 +0200 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2016-07-05 14:06:22 +0200 |
commit | 69aaea0663eb3b05d0f16bd045000e54b8f109b1 (patch) | |
tree | c3d4d2f2beac490ce640b791da252fa323b81e0f /gcc/fortran | |
parent | b0ad2d78b237380c47f92a8f61e257a1e434a3fe (diff) | |
download | gcc-69aaea0663eb3b05d0f16bd045000e54b8f109b1.zip gcc-69aaea0663eb3b05d0f16bd045000e54b8f109b1.tar.gz gcc-69aaea0663eb3b05d0f16bd045000e54b8f109b1.tar.bz2 |
re PR fortran/71623 (Segfault when allocating deferred-length characters to size of a pointer)
gcc/fortran/ChangeLog:
2016-07-05 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/71623
* trans-stmt.c (gfc_trans_allocate): Add code of pre block of typespec
in allocate to parent block.
gcc/testsuite/ChangeLog:
2016-07-05 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/71623
* gfortran.dg/deferred_character_17.f90: New test.
From-SVN: r238002
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-stmt.c | 21 |
2 files changed, 22 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f833b97..0947d6d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-07-05 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/71623 + * trans-stmt.c (gfc_trans_allocate): Add code of pre block of typespec + in allocate to parent block. + 2016-07-04 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/66575 diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 84bf749..5aa7778 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -5696,9 +5696,11 @@ gfc_trans_allocate (gfc_code * code) tmp = gfc_get_char_type (code->ext.alloc.ts.kind); tmp = TYPE_SIZE_UNIT (tmp); tmp = fold_convert (TREE_TYPE (se_sz.expr), tmp); + gfc_add_block_to_block (&block, &se_sz.pre); expr3_esize = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (se_sz.expr), tmp, se_sz.expr); + expr3_esize = gfc_evaluate_now (expr3_esize, &block); } } @@ -5897,6 +5899,7 @@ gfc_trans_allocate (gfc_code * code) source= or mold= expression. */ gfc_init_se (&se_sz, NULL); gfc_conv_expr (&se_sz, code->ext.alloc.ts.u.cl->length); + gfc_add_block_to_block (&block, &se_sz.pre); gfc_add_modify (&block, al_len, fold_convert (TREE_TYPE (al_len), se_sz.expr)); @@ -5981,11 +5984,19 @@ gfc_trans_allocate (gfc_code * code) specified by a type spec for deferred length character arrays or unlimited polymorphic objects without a source= or mold= expression. */ - gfc_init_se (&se_sz, NULL); - gfc_conv_expr (&se_sz, code->ext.alloc.ts.u.cl->length); - gfc_add_modify (&block, al_len, - fold_convert (TREE_TYPE (al_len), - se_sz.expr)); + if (expr3_esize == NULL_TREE || code->ext.alloc.ts.kind != 1) + { + gfc_init_se (&se_sz, NULL); + gfc_conv_expr (&se_sz, code->ext.alloc.ts.u.cl->length); + gfc_add_block_to_block (&block, &se_sz.pre); + gfc_add_modify (&block, al_len, + fold_convert (TREE_TYPE (al_len), + se_sz.expr)); + } + else + gfc_add_modify (&block, al_len, + fold_convert (TREE_TYPE (al_len), + expr3_esize)); } else /* No length information needed, because type to allocate |