aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Koenig <Thomas.Koenig@online.de>2006-02-14 19:25:36 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2006-02-14 19:25:36 +0000
commitce99d59440477170c00aa9ef2c2dfacb42e6f25f (patch)
tree3d3ad82e9ba7346317222ce9dd164bc1c566f55b /gcc
parent89031799f4009b0416164a7e77a7b008e63d94ad (diff)
downloadgcc-ce99d59440477170c00aa9ef2c2dfacb42e6f25f.zip
gcc-ce99d59440477170c00aa9ef2c2dfacb42e6f25f.tar.gz
gcc-ce99d59440477170c00aa9ef2c2dfacb42e6f25f.tar.bz2
re PR fortran/25045 ([4.1 only] DIM argument of PRODUCT is not optional)
2006-02-14 Thomas Koenig <Thomas.Koenig@online.de> 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 <Thomas.Koenig@online.de> PR fortran/25045 * optional_dim.f90: New test. From-SVN: r110994
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/check.c29
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/optional_dim.f9010
4 files changed, 36 insertions, 16 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index faf6975..4cff233 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2006-02-14 Thomas Koenig <Thomas.Koenig@online.de>
+
+ 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 <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/26277
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index dc6541c8..6d3fd3d 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 cb15ef6..5d4bfaf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-02-14 Thomas Koenig <Thomas.Koenig@online.de>
+
+ PR fortran/25045
+ * optional_dim.f90: New test.
+
2006-02-14 Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
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 0000000..dd201fb
--- /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
+