diff options
author | Tobias Burnus <burnus@net-b.de> | 2008-07-19 19:20:26 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2008-07-19 19:20:26 +0200 |
commit | d1a296c11ab091c896267dee5a3d831731fd3143 (patch) | |
tree | ff18b3e0b7885ebb943b679a3de17f7ce56abf8c /gcc/fortran | |
parent | 7b901ac47fb235195a14d401567b0b2677ad8a03 (diff) | |
download | gcc-d1a296c11ab091c896267dee5a3d831731fd3143.zip gcc-d1a296c11ab091c896267dee5a3d831731fd3143.tar.gz gcc-d1a296c11ab091c896267dee5a3d831731fd3143.tar.bz2 |
check.c (gfc_check_cshift,gfc_check_eoshift,gfc_check_unpack): Add rank checks for cshift's shift and eoshift's shift and boundary args.
2008-07-19 Tobias Burnus <burnus@net-b.de>
* check.c (gfc_check_cshift,gfc_check_eoshift,gfc_check_unpack): Add
rank checks for cshift's shift and eoshift's shift and boundary args.
(gfc_check_unpack): Add rank and shape tests for unpack.
2008-07-19 Tobias Burnus <burnus@net-b.de>
* gfortran.dg/intrinsic_argument_conformance_2.f90: New.
* gfortran.dg/zero_sized_1.f90: Fix conformance bugs.
From-SVN: r137983
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/check.c | 62 |
2 files changed, 63 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 87279c4..6077028 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2008-07-19 Tobias Burnus <burnus@net-b.de> + + * check.c (gfc_check_cshift,gfc_check_eoshift,gfc_check_unpack): Add rank + checks for cshift's shift and eoshift's shift and boundary args. + (gfc_check_unpack): Add rank and shape tests for unpack. + 2008-07-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * gfortran.h (new): Remove macro. diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index c0f9891..4132d83a 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -876,11 +876,16 @@ gfc_check_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim) if (scalar_check (shift, 1) == FAILURE) return FAILURE; } - else + else if (shift->rank != array->rank - 1 && shift->rank != 0) { - /* TODO: more requirements on shift parameter. */ + gfc_error ("SHIFT argument at %L of CSHIFT must have rank %d or be a " + "scalar", &shift->where, array->rank - 1); + return FAILURE; } + /* TODO: Add shape conformance check between array (w/o dimension dim) + and shift. */ + if (dim_check (dim, 2, true) == FAILURE) return FAILURE; @@ -1037,17 +1042,45 @@ gfc_check_eoshift (gfc_expr *array, gfc_expr *shift, gfc_expr *boundary, if (scalar_check (shift, 2) == FAILURE) return FAILURE; } - else + else if (shift->rank != array->rank - 1 && shift->rank != 0) { - /* TODO: more weird restrictions on shift. */ + gfc_error ("SHIFT argument at %L of EOSHIFT must have rank %d or be a " + "scalar", &shift->where, array->rank - 1); + return FAILURE; } + /* TODO: Add shape conformance check between array (w/o dimension dim) + and shift. */ + if (boundary != NULL) { if (same_type_check (array, 0, boundary, 2) == FAILURE) return FAILURE; - /* TODO: more restrictions on boundary. */ + if (array->rank == 1) + { + if (scalar_check (boundary, 2) == FAILURE) + return FAILURE; + } + else if (boundary->rank != array->rank - 1 && boundary->rank != 0) + { + gfc_error ("BOUNDARY argument at %L of EOSHIFT must have rank %d or be " + "a scalar", &boundary->where, array->rank - 1); + return FAILURE; + } + + if (shift->rank == boundary->rank) + { + int i; + for (i = 0; i < shift->rank; i++) + if (! identical_dimen_shape (shift, i, boundary, i)) + { + gfc_error ("Different shape in dimension %d for SHIFT and " + "BOUNDARY arguments of EOSHIFT at %L", shift->rank, + &boundary->where); + return FAILURE; + } + } } if (dim_check (dim, 4, true) == FAILURE) @@ -2886,6 +2919,25 @@ gfc_check_unpack (gfc_expr *vector, gfc_expr *mask, gfc_expr *field) if (same_type_check (vector, 0, field, 2) == FAILURE) return FAILURE; + if (mask->rank != field->rank && field->rank != 0) + { + gfc_error ("FIELD argument at %L of UNPACK must have the same rank as " + "MASK or be a scalar", &field->where); + return FAILURE; + } + + if (mask->rank == field->rank) + { + int i; + for (i = 0; i < field->rank; i++) + if (! identical_dimen_shape (mask, i, field, i)) + { + gfc_error ("Different shape in dimension %d for MASK and FIELD " + "arguments of UNPACK at %L", mask->rank, &field->where); + return FAILURE; + } + } + return SUCCESS; } |