diff mbox

[Fortran] Fix for PR 61999, dot_product simplification

Message ID 53E6A063.9000707@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig Aug. 9, 2014, 10:27 p.m. UTC
Hello world,

the attached patch fixes the regression by converting the arguments
to dot_product to the proper types.

Regression-tested on x86_64-unknown-linux-gnu.

OK for all affected branches (trunk, 4.9 and 4.8)?

	Thomas

2014-08-10  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/61999
        * simplify.c (gfc_simplify_dot_product): Convert types of
        vectors before calculating the result.

2014-08-10  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/61999
        * gfortran.dg/dot_product_3.f90:  New test case.

Comments

Steve Kargl Aug. 9, 2014, 10:32 p.m. UTC | #1
On Sun, Aug 10, 2014 at 12:27:47AM +0200, Thomas Koenig wrote:
> 
> the attached patch fixes the regression by converting the arguments
> to dot_product to the proper types.
> 
> Regression-tested on x86_64-unknown-linux-gnu.
> 
> OK for all affected branches (trunk, 4.9 and 4.8)?
> 

Yes.
diff mbox

Patch

Index: simplify.c
===================================================================
--- simplify.c	(Revision 213778)
+++ simplify.c	(Arbeitskopie)
@@ -1882,6 +1882,9 @@ 
 gfc_expr*
 gfc_simplify_dot_product (gfc_expr *vector_a, gfc_expr *vector_b)
 {
+
+  gfc_expr temp;
+
   if (!is_constant_array_expr (vector_a)
       || !is_constant_array_expr (vector_b))
     return NULL;
@@ -1888,8 +1891,14 @@ 
 
   gcc_assert (vector_a->rank == 1);
   gcc_assert (vector_b->rank == 1);
-  gcc_assert (gfc_compare_types (&vector_a->ts, &vector_b->ts));
 
+  temp.expr_type = EXPR_OP;
+  gfc_clear_ts (&temp.ts);
+  temp.value.op.op = INTRINSIC_NONE;
+  temp.value.op.op1 = vector_a;
+  temp.value.op.op2 = vector_b;
+  gfc_type_convert_binary (&temp, 1);
+
   return compute_dot_product (vector_a, 1, 0, vector_b, 1, 0, true);
 }