diff options
| author | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-19 19:51:21 +0000 |
|---|---|---|
| committer | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-19 19:51:21 +0000 |
| commit | 7c710787c0656d278c5bf2db28409d9f20394041 (patch) | |
| tree | 575373a2aa4da956c33fd765439fba98b08238bf | |
| parent | 87929f5d45f7f2feb340e66afe9801f96f52fa75 (diff) | |
| download | ppe42-gcc-7c710787c0656d278c5bf2db28409d9f20394041.tar.gz ppe42-gcc-7c710787c0656d278c5bf2db28409d9f20394041.zip | |
PR fortran/31974
* trans-array.c (gfc_trans_auto_array_allocation): Avoid
multiplication of mismatched types.
* gfortran.dg/char_allocation_1.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124858 138bc75d-0d04-0410-961f-82ee72b054a4
| -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 08c9d33a0d1..2c9820b7f71 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 61e35543fe3..dfbdef0b594 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 56565874039..787e256a410 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 00000000000..119badb4d10 --- /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 |

