From 48b87d3c34410050081bc9e1262ad091863656aa Mon Sep 17 00:00:00 2001 From: tkoenig Date: Tue, 14 Feb 2006 19:25:36 +0000 Subject: [PATCH] 2006-02-14 Thomas Koenig PR fortran/25045 * check.c (dim_check): Perform all checks if dim is optional. (gfc_check_minloc_maxloc): Use dim_check and dim_rank_check to check dim argument. (check_reduction): Likewise. 2006-02-14 Thomas Koenig PR fortran/25045 * optional_dim.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110994 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/check.c | 29 +++++++++++++---------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/optional_dim.f90 | 10 ++++++++++ 4 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/optional_dim.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index faf6975e2df..4cff233a4e9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2006-02-14 Thomas Koenig + + PR fortran/25045 + * check.c (dim_check): Perform all checks if dim is optional. + (gfc_check_minloc_maxloc): Use dim_check and dim_rank_check + to check dim argument. + (check_reduction): Likewise. + 2006-02-14 Tobias Schl�üter PR fortran/26277 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index dc6541c8598..6d3fd3d825e 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -295,16 +295,8 @@ variable_check (gfc_expr * e, int n) static try dim_check (gfc_expr * dim, int n, int optional) { - if (optional) - { - if (dim == NULL) - return SUCCESS; - - if (nonoptional_check (dim, n) == FAILURE) - return FAILURE; - - return SUCCESS; - } + if (optional && dim == NULL) + return SUCCESS; if (dim == NULL) { @@ -319,6 +311,9 @@ dim_check (gfc_expr * dim, int n, int optional) if (scalar_check (dim, n) == FAILURE) return FAILURE; + if (nonoptional_check (dim, n) == FAILURE) + return FAILURE; + return SUCCESS; } @@ -1578,9 +1573,10 @@ gfc_check_minloc_maxloc (gfc_actual_arglist * ap) ap->next->next->expr = m; } - if (d != NULL - && (scalar_check (d, 1) == FAILURE - || type_check (d, 1, BT_INTEGER) == FAILURE)) + if (dim_check (d, 1, 1) == FAILURE) + return FAILURE; + + if (dim_rank_check (d, a, 0) == FAILURE) return FAILURE; if (m != NULL && type_check (m, 2, BT_LOGICAL) == FAILURE) @@ -1634,9 +1630,10 @@ check_reduction (gfc_actual_arglist * ap) ap->next->next->expr = m; } - if (d != NULL - && (scalar_check (d, 1) == FAILURE - || type_check (d, 1, BT_INTEGER) == FAILURE)) + if (dim_check (d, 1, 1) == FAILURE) + return FAILURE; + + if (dim_rank_check (d, a, 0) == FAILURE) return FAILURE; if (m != NULL && type_check (m, 2, BT_LOGICAL) == FAILURE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb15ef61fec..5d4bfafd87f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-02-14 Thomas Koenig + + PR fortran/25045 + * optional_dim.f90: New test. + 2006-02-14 Tobias Schlüter PR fortran/26277 diff --git a/gcc/testsuite/gfortran.dg/optional_dim.f90 b/gcc/testsuite/gfortran.dg/optional_dim.f90 new file mode 100644 index 00000000000..dd201fbf48a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/optional_dim.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +subroutine foo(a,n) + real, dimension(2) :: a + integer, optional :: n + print *,maxloc(a,dim=n) ! { dg-error "must not be OPTIONAL" } + print *,maxloc(a,dim=4) ! { dg-error "is not a valid dimension index" } + print *,maxval(a,dim=n) ! { dg-error "must not be OPTIONAL" } + print *,maxval(a,dim=4) ! { dg-error "is not a valid dimension index" } +end subroutine foo + -- 2.11.4.GIT