aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2008-05-14 21:36:26 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2008-05-14 21:36:26 +0000
commit6401bf9cad029c264ff65db946c8e31ce998db13 (patch)
treedf80bd35e852b8a95650c6aa6011baacf3b5d0b0 /gcc/fortran
parent16f2a7a4a53554e454d5373e6ef689da8fc84ef4 (diff)
downloadgcc-6401bf9cad029c264ff65db946c8e31ce998db13.zip
gcc-6401bf9cad029c264ff65db946c8e31ce998db13.tar.gz
gcc-6401bf9cad029c264ff65db946c8e31ce998db13.tar.bz2
re PR fortran/36186 (Wrong handling of BOZ in CMPLX)
PR fortran/36186 * simplify.c (only_convert_cmplx_boz): New function. (gfc_simplify_cmplx, gfc_simplify_complex, gfc_simplify_dcmplx): Call only_convert_cmplx_boz. * gfortran.dg/boz_11.f90: New test. * gfortran.dg/boz_12.f90: New test. From-SVN: r135308
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog13
-rw-r--r--gcc/fortran/simplify.c48
2 files changed, 49 insertions, 12 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 2facb39..c38717c 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,8 +1,15 @@
+2008-05-14 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR fortran/36186
+ * simplify.c (only_convert_cmplx_boz): New function.
+ (gfc_simplify_cmplx, gfc_simplify_complex, gfc_simplify_dcmplx):
+ Call only_convert_cmplx_boz.
+
2008-05-14 Paul Thomas <pault@gcc.gnu.org>
- PR fortran/36233
- * interface.c (compare_actual_formal): Do not check sizes if the
- actual is BT_PROCEDURE.
+ PR fortran/36233
+ * interface.c (compare_actual_formal): Do not check sizes if the
+ actual is BT_PROCEDURE.
2008-05-14 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index e87804c..066bf28 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -928,19 +928,49 @@ simplify_cmplx (const char *name, gfc_expr *x, gfc_expr *y, int kind)
}
+/* Function called when we won't simplify an expression like CMPLX (or
+ COMPLEX or DCMPLX) but still want to convert BOZ arguments. */
+
+static gfc_expr *
+only_convert_cmplx_boz (gfc_expr *x, gfc_expr *y, int kind)
+{
+ if (x->is_boz)
+ {
+ gfc_typespec ts;
+ gfc_clear_ts (&ts);
+ ts.type = BT_REAL;
+ ts.kind = kind;
+ if (!gfc_convert_boz (x, &ts))
+ return &gfc_bad_expr;
+ }
+
+ if (y && y->is_boz)
+ {
+ gfc_typespec ts;
+ gfc_clear_ts (&ts);
+ ts.type = BT_REAL;
+ ts.kind = kind;
+ if (!gfc_convert_boz (y, &ts))
+ return &gfc_bad_expr;
+ }
+
+ return NULL;
+}
+
+
gfc_expr *
gfc_simplify_cmplx (gfc_expr *x, gfc_expr *y, gfc_expr *k)
{
int kind;
- if (x->expr_type != EXPR_CONSTANT
- || (y != NULL && y->expr_type != EXPR_CONSTANT))
- return NULL;
-
kind = get_kind (BT_REAL, k, "CMPLX", gfc_default_real_kind);
if (kind == -1)
return &gfc_bad_expr;
+ if (x->expr_type != EXPR_CONSTANT
+ || (y != NULL && y->expr_type != EXPR_CONSTANT))
+ return only_convert_cmplx_boz (x, y, kind);
+
return simplify_cmplx ("CMPLX", x, y, kind);
}
@@ -950,10 +980,6 @@ gfc_simplify_complex (gfc_expr *x, gfc_expr *y)
{
int kind;
- if (x->expr_type != EXPR_CONSTANT
- || (y != NULL && y->expr_type != EXPR_CONSTANT))
- return NULL;
-
if (x->ts.type == BT_INTEGER)
{
if (y->ts.type == BT_INTEGER)
@@ -969,6 +995,10 @@ gfc_simplify_complex (gfc_expr *x, gfc_expr *y)
kind = x->ts.kind;
}
+ if (x->expr_type != EXPR_CONSTANT
+ || (y != NULL && y->expr_type != EXPR_CONSTANT))
+ return only_convert_cmplx_boz (x, y, kind);
+
return simplify_cmplx ("COMPLEX", x, y, kind);
}
@@ -1052,7 +1082,7 @@ gfc_simplify_dcmplx (gfc_expr *x, gfc_expr *y)
if (x->expr_type != EXPR_CONSTANT
|| (y != NULL && y->expr_type != EXPR_CONSTANT))
- return NULL;
+ return only_convert_cmplx_boz (x, y, gfc_default_double_kind);
return simplify_cmplx ("DCMPLX", x, y, gfc_default_double_kind);
}