re PR fortran/40290 (Spurious warning on REAL*COMPLEX with -Wconversion)
authorDaniel Franke <franke.daniel@gmail.com>
Fri, 11 Dec 2009 21:08:39 +0000 (16:08 -0500)
committerDaniel Franke <dfranke@gcc.gnu.org>
Fri, 11 Dec 2009 21:08:39 +0000 (16:08 -0500)
2009-12-11  Daniel Franke  <franke.daniel@gmail.com>

        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
gcc/fortran/arith.c
gcc/fortran/expr.c
gcc/fortran/gfortran.h
gcc/fortran/iresolve.c
gcc/fortran/resolve.c

index 7000e25e5f87644e10ba90c40a208943e4606e01..21c615483ede7fb4220ba0f1ee56e5c2d9c4f392 100644 (file)
@@ -1,3 +1,13 @@
+2009-12-11  Daniel Franke  <franke.daniel@gmail.com>
+
+        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  <janus@gcc.gnu.org>
 
        PR fortran/42335
index d119d1231f9e65e64ca75cb41fe5d7b37da9efd0..674b2462a4924a258e2dcc8be23db46f60afdf5d 100644 (file)
@@ -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
index f0cfd1896288d595629c48e3dcb79186e494d327..35918a69f9def5d9ad4e9d625456e929324a7724 100644 (file)
@@ -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;
index 340e0149902675a7f5248106a40c44826d6ca894..9ea5ad17b267fd26e33479862a8e9900d569269f 100644 (file)
@@ -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 *);
index 1f8f9bce7137fa928cdbe4c9cbe184a25fdeeb6c..e2089b26907a428e25f2c6c75b4345854a865572 100644 (file)
@@ -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;
     }
 
index 8d2be53b2cd19052f4d6d2f2fd257f29929866c8..00bd44135299916093f71585569ed64404770ecb 100644 (file)
@@ -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;