From e2018d20297a95c30da9b88763292e9a7420fa2a Mon Sep 17 00:00:00 2001 From: burnus Date: Sat, 6 Sep 2008 15:27:50 +0000 Subject: [PATCH] 2008-09-06 Steven G. Kargl PR fortran/36153 * fortran/resolve.c (resolve_function): Shortcircuit for SIZE and UBOUND if 2nd argument is KIND. 2008-09-06 Tobias Burnus PR fortran/36153 * gfortran.dg/size_kind.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140063 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/resolve.c | 9 +++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/size_kind.f90 | 25 +++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/size_kind.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e3f2dcd..0e64d91 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,11 @@ 2008-09-06 Steven G. Kargl + PR fortran/36153 + * fortran/resolve.c (resolve_function): Shortcircuit for SIZE and + UBOUND if 2nd argument is KIND. + +2008-09-06 Steven G. Kargl + PR fortran/33229 * resolve.c (resolve_function): An intrinsic subroutine should not be called as a function. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 485d331..05f2c14 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -2336,17 +2336,18 @@ resolve_function (gfc_expr *expr) assumed size array argument. UBOUND and SIZE have to be excluded from the check if the second argument is anything than a constant. */ - int inquiry; - inquiry = GENERIC_ID == GFC_ISYM_UBOUND - || GENERIC_ID == GFC_ISYM_SIZE; for (arg = expr->value.function.actual; arg; arg = arg->next) { - if (inquiry && arg->next != NULL && arg->next->expr) + if ((GENERIC_ID == GFC_ISYM_UBOUND || GENERIC_ID == GFC_ISYM_SIZE) + && arg->next != NULL && arg->next->expr) { if (arg->next->expr->expr_type != EXPR_CONSTANT) break; + if (arg->next->name && strncmp(arg->next->name, "kind", 4) == 0) + break; + if ((int)mpz_get_si (arg->next->expr->value.integer) < arg->expr->rank) break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c094425..aaeb46c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-09-06 Tobias Burnus + + PR fortran/36153 + * gfortran.dg/size_kind.f90: New test. + 2008-09-06 Steven G. Kargl PR fortran/33229 diff --git a/gcc/testsuite/gfortran.dg/size_kind.f90 b/gcc/testsuite/gfortran.dg/size_kind.f90 new file mode 100644 index 0000000..5ec6f7e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/size_kind.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! +! PR fortran/36153 +! Contributed by Jonathan Hogg +! +program test_64 + implicit none + + integer, parameter :: long = selected_int_kind(18) + integer, parameter :: short = kind(0) + + integer(long), parameter :: big_sz = huge(0_short)+1000_long + integer(long), parameter :: max_32 = huge(0_short) + integer, dimension(:), allocatable :: array + + integer(long) :: i + + print *, "2**31 = ", 2_long**31 + print *, "max_32 = ", max_32 + print *, "big_sz = ", big_sz + + allocate(array(big_sz)) + print *, "sz = ", size(array) + print *, "sz = ", size(array, kind=long) +end program -- 2.7.4