diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2007-05-19 19:51:21 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2007-05-19 19:51:21 +0000 |
commit | 61f70bf208644b9b2f3b76ba9c324eb7c4a4cfa1 (patch) | |
tree | 575373a2aa4da956c33fd765439fba98b08238bf /gcc | |
parent | e9d416168f5d1782664609c71972e41eb2523a21 (diff) | |
download | gcc-61f70bf208644b9b2f3b76ba9c324eb7c4a4cfa1.zip gcc-61f70bf208644b9b2f3b76ba9c324eb7c4a4cfa1.tar.gz gcc-61f70bf208644b9b2f3b76ba9c324eb7c4a4cfa1.tar.bz2 |
re PR fortran/31974 ([4.2]: array allocation multiplication of mismatched types)
PR fortran/31974
* trans-array.c (gfc_trans_auto_array_allocation): Avoid
multiplication of mismatched types.
* gfortran.dg/char_allocation_1.f90: New test.
From-SVN: r124858
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-array.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/char_allocation_1.f90 | 11 |
4 files changed, 24 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 08c9d33..2c9820b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-05-19 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + + PR fortran/31974 + * trans-array.c (gfc_trans_auto_array_allocation): Avoid + multiplication of mismatched types. + 2007-05-18 Daniel Franke <franke.daniel@gmail.com> PR fortran/24633 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 61e3554..dfbdef0 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -3846,7 +3846,8 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, tree fnbody) /* The size is the number of elements in the array, so multiply by the size of an element to get the total size. */ tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type)); - size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, tmp); + size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, + fold_convert (gfc_array_index_type, tmp)); /* Allocate memory to hold the data. */ tmp = gfc_call_malloc (&block, TREE_TYPE (decl), size); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5656587..787e256 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-05-19 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + + PR fortran/31974 + * gfortran.dg/char_allocation_1.f90: New test. + 2007-05-19 Manuel Lopez-Ibanez <manu@gcc.gnu.org> * gcc.dg/Wconversion-integer.c: Group testcases and add more. diff --git a/gcc/testsuite/gfortran.dg/char_allocation_1.f90 b/gcc/testsuite/gfortran.dg/char_allocation_1.f90 new file mode 100644 index 0000000..119badb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/char_allocation_1.f90 @@ -0,0 +1,11 @@ +! PR fortran/31974 +! { dg-do run } + subroutine foo (n) + integer :: n + character (len = n) :: v(n) + v = '' + if (any (v /= '')) call abort + end subroutine foo + + call foo(7) + end |