aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2007-09-13 19:02:31 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2007-09-13 19:02:31 +0000
commit76896993c25ad2143fbb0a1d7fbfcbdea30e41f0 (patch)
tree47a7bb8af7e96a7c7a67312e8a96d2f04d8ce3b7 /gcc/fortran
parent1d7d5ac4e8c62c26923e0a747afe5df3f5d13011 (diff)
downloadgcc-76896993c25ad2143fbb0a1d7fbfcbdea30e41f0.zip
gcc-76896993c25ad2143fbb0a1d7fbfcbdea30e41f0.tar.gz
gcc-76896993c25ad2143fbb0a1d7fbfcbdea30e41f0.tar.bz2
iresolve.c (resolve_mask_arg): If a mask is an array expression, convert it to kind=1.
2007-09-13 Thomas Koenig <tkoenig@gcc.gnu.org> * iresolve.c (resolve_mask_arg): If a mask is an array expression, convert it to kind=1. From-SVN: r128477
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/iresolve.c32
2 files changed, 28 insertions, 9 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0484460..8760abe 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2007-09-13 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ * iresolve.c (resolve_mask_arg): If a mask is an array
+ expression, convert it to kind=1.
+
2007-09-13 Tobias Burnus <burnus@net-b.de>
PR fortran/33343
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index 38da76b..3205bebc 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -78,18 +78,32 @@ static void
resolve_mask_arg (gfc_expr *mask)
{
- /* The mask can be any kind for an array.
- For the scalar case, coerce it to kind=4 unconditionally
- (because this is the only kind we have a library function
- for). */
+ gfc_typespec ts;
- if (mask->rank == 0 && mask->ts.kind != 4)
+ if (mask->rank == 0)
{
- gfc_typespec ts;
+ /* For the scalar case, coerce the mask to kind=4 unconditionally
+ (because this is the only kind we have a library function
+ for). */
- ts.type = BT_LOGICAL;
- ts.kind = 4;
- gfc_convert_type (mask, &ts, 2);
+ if (mask->ts.kind != 4)
+ {
+ ts.type = BT_LOGICAL;
+ ts.kind = 4;
+ gfc_convert_type (mask, &ts, 2);
+ }
+ }
+ else
+ {
+ /* In the library, we access the mask with a GFC_LOGICAL_1
+ argument. No need to waste memory if we are about to create
+ a temporary array. */
+ if (mask->expr_type == EXPR_OP)
+ {
+ ts.type = BT_LOGICAL;
+ ts.kind = 1;
+ gfc_convert_type (mask, &ts, 2);
+ }
}
}