From c13af44bcc9d9435b4a537d189e5d3b6edffe7fe Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Fri, 14 May 2010 21:02:26 +0000 Subject: [PATCH] re PR fortran/44135 (Negative array bounds lead to spurious warning) 2010-05-14 Steven G. Kargl PR fortran/44135 * gfortran.dg/actual_array_interface_2.f90: New test. 2010-05-14 Steven G. Kargl PR fortran/44135 * fortran/interface.c (get_sym_storage_size): Use signed instead of unsigned mpz_get_?i routines. From-SVN: r159415 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/interface.c | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ .../gfortran.dg/actual_array_interface_2.f90 | 13 +++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/actual_array_interface_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c766d40a568..a95d16d6dd2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2010-05-14 Steven G. Kargl + + PR fortran/44135 + * fortran/interface.c (get_sym_storage_size): Use signed instead of + unsigned mpz_get_?i routines. + 2010-05-14 Jakub Jelinek * trans.c (trans_code): Set backend locus early. diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 38adf9b7393..4bcc63e1963 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1645,8 +1645,8 @@ get_sym_storage_size (gfc_symbol *sym) || sym->as->lower[i]->expr_type != EXPR_CONSTANT) return 0; - elements *= mpz_get_ui (sym->as->upper[i]->value.integer) - - mpz_get_ui (sym->as->lower[i]->value.integer) + 1L; + elements *= mpz_get_si (sym->as->upper[i]->value.integer) + - mpz_get_si (sym->as->lower[i]->value.integer) + 1L; } return strlen*elements; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b96b9a315a5..4cf711266f2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-05-14 Steven G. Kargl + + PR fortran/44135 + * gfortran.dg/actual_array_interface_2.f90: New test. + 2010-05-14 Richard Guenther PR tree-optimization/44119 diff --git a/gcc/testsuite/gfortran.dg/actual_array_interface_2.f90 b/gcc/testsuite/gfortran.dg/actual_array_interface_2.f90 new file mode 100644 index 00000000000..ae429b7d9a9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/actual_array_interface_2.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +program gprogram + implicit none + real, dimension(-2:0) :: my_arr + call fill_array(my_arr) + contains + subroutine fill_array(arr) + implicit none + real, dimension(-2:0), intent(out) :: arr + arr = 42 + end subroutine fill_array +end program gprogram +