From dcea1b2f86047a9b234fb742bdb3ce268262dfa7 Mon Sep 17 00:00:00 2001 From: Daniel Franke Date: Fri, 11 Dec 2009 16:08:39 -0500 Subject: [PATCH] re PR fortran/40290 (Spurious warning on REAL*COMPLEX with -Wconversion) 2009-12-11 Daniel Franke PR fortran/40290 * expr.c (gfc_type_convert_binary): Added warn-on-conversion flag, passed on to gfc_convert_type_warn() instead of gfc_convert_type(); enabled warnings on all callers but ... * arith.c (eval_intrinsic): Disabled warnings on implicit type conversion. * gfortran.h gfc_type_convert_binary): Adjusted prototype. From-SVN: r155179 --- gcc/fortran/ChangeLog | 10 ++++++++++ gcc/fortran/arith.c | 2 +- gcc/fortran/expr.c | 17 +++++++++-------- gcc/fortran/gfortran.h | 2 +- gcc/fortran/iresolve.c | 4 ++-- gcc/fortran/resolve.c | 4 ++-- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7000e25e5f8..21c615483ed 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2009-12-11 Daniel Franke + + PR fortran/40290 + * expr.c (gfc_type_convert_binary): Added warn-on-conversion flag, + passed on to gfc_convert_type_warn() instead of gfc_convert_type(); + enabled warnings on all callers but ... + * arith.c (eval_intrinsic): Disabled warnings on implicit type + conversion. + * gfortran.h gfc_type_convert_binary): Adjusted prototype. + 2009-12-11 Janus Weil PR fortran/42335 diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index d119d1231f9..674b2462a49 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -1577,7 +1577,7 @@ eval_intrinsic (gfc_intrinsic_op op, temp.value.op.op1 = op1; temp.value.op.op2 = op2; - gfc_type_convert_binary (&temp); + gfc_type_convert_binary (&temp, 0); if (op == INTRINSIC_EQ || op == INTRINSIC_NE || op == INTRINSIC_GE || op == INTRINSIC_GT diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index f0cfd189628..35918a69f9d 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -653,7 +653,8 @@ gfc_build_conversion (gfc_expr *e) /* Given an expression node with some sort of numeric binary expression, insert type conversions required to make the operands - have the same type. + have the same type. Conversion warnings are disabled if wconversion + is set to 0. The exception is that the operands of an exponential don't have to have the same type. If possible, the base is promoted to the type @@ -661,7 +662,7 @@ gfc_build_conversion (gfc_expr *e) 1.0**2 stays as it is. */ void -gfc_type_convert_binary (gfc_expr *e) +gfc_type_convert_binary (gfc_expr *e, int wconversion) { gfc_expr *op1, *op2; @@ -685,9 +686,9 @@ gfc_type_convert_binary (gfc_expr *e) } if (op1->ts.kind > op2->ts.kind) - gfc_convert_type (op2, &op1->ts, 2); + gfc_convert_type_warn (op2, &op1->ts, 2, wconversion); else - gfc_convert_type (op1, &op2->ts, 2); + gfc_convert_type_warn (op1, &op2->ts, 2, wconversion); e->ts = op1->ts; goto done; @@ -702,14 +703,14 @@ gfc_type_convert_binary (gfc_expr *e) if (e->value.op.op == INTRINSIC_POWER) goto done; - gfc_convert_type (e->value.op.op2, &e->ts, 2); + gfc_convert_type_warn (e->value.op.op2, &e->ts, 2, wconversion); goto done; } if (op1->ts.type == BT_INTEGER) { e->ts = op2->ts; - gfc_convert_type (e->value.op.op1, &e->ts, 2); + gfc_convert_type_warn (e->value.op.op1, &e->ts, 2, wconversion); goto done; } @@ -720,9 +721,9 @@ gfc_type_convert_binary (gfc_expr *e) else e->ts.kind = op2->ts.kind; if (op1->ts.type != BT_COMPLEX || op1->ts.kind != e->ts.kind) - gfc_convert_type (e->value.op.op1, &e->ts, 2); + gfc_convert_type_warn (e->value.op.op1, &e->ts, 2, wconversion); if (op2->ts.type != BT_COMPLEX || op2->ts.kind != e->ts.kind) - gfc_convert_type (e->value.op.op2, &e->ts, 2); + gfc_convert_type_warn (e->value.op.op2, &e->ts, 2, wconversion); done: return; diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 340e0149902..9ea5ad17b26 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2588,7 +2588,7 @@ bool is_subref_array (gfc_expr *); void gfc_add_component_ref (gfc_expr *, const char *); gfc_expr *gfc_build_conversion (gfc_expr *); void gfc_free_ref_list (gfc_ref *); -void gfc_type_convert_binary (gfc_expr *); +void gfc_type_convert_binary (gfc_expr *, int); int gfc_is_constant_expr (gfc_expr *); gfc_try gfc_simplify_expr (gfc_expr *, int); int gfc_has_vector_index (gfc_expr *); diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c index 1f8f9bce713..e2089b26907 100644 --- a/gcc/fortran/iresolve.c +++ b/gcc/fortran/iresolve.c @@ -702,7 +702,7 @@ gfc_resolve_dot_product (gfc_expr *f, gfc_expr *a, gfc_expr *b) temp.value.op.op = INTRINSIC_NONE; temp.value.op.op1 = a; temp.value.op.op2 = b; - gfc_type_convert_binary (&temp); + gfc_type_convert_binary (&temp, 1); f->ts = temp.ts; f->value.function.name = gfc_get_string (PREFIX ("dot_product_%c%d"), @@ -1380,7 +1380,7 @@ gfc_resolve_matmul (gfc_expr *f, gfc_expr *a, gfc_expr *b) temp.value.op.op = INTRINSIC_NONE; temp.value.op.op1 = a; temp.value.op.op2 = b; - gfc_type_convert_binary (&temp); + gfc_type_convert_binary (&temp, 1); f->ts = temp.ts; } diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 8d2be53b2cd..00bd4413529 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -3320,7 +3320,7 @@ resolve_operator (gfc_expr *e) case INTRINSIC_POWER: if (gfc_numeric_ts (&op1->ts) && gfc_numeric_ts (&op2->ts)) { - gfc_type_convert_binary (e); + gfc_type_convert_binary (e, 1); break; } @@ -3407,7 +3407,7 @@ resolve_operator (gfc_expr *e) if (gfc_numeric_ts (&op1->ts) && gfc_numeric_ts (&op2->ts)) { - gfc_type_convert_binary (e); + gfc_type_convert_binary (e, 1); e->ts.type = BT_LOGICAL; e->ts.kind = gfc_default_logical_kind; -- 2.30.2