re PR fortran/61999 (gfc_simplify_dot_product causes ICE for constant arguments)

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.

From-SVN: r213782
This commit is contained in:
Thomas Koenig 2014-08-09 22:38:46 +00:00
parent 726540aa29
commit 4d05134010
4 changed files with 36 additions and 1 deletions

View File

@ -1,3 +1,9 @@
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-02 Trevor Saunders <tsaunders@mozilla.com>
* openmp.c, trans-decl.c: Use hash_set instead of pointer_set.

View File

@ -1882,13 +1882,22 @@ gfc_simplify_dim (gfc_expr *x, gfc_expr *y)
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;
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);
}

View File

@ -1,3 +1,8 @@
2014-08-10 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/61999
* gfortran.dg/dot_product_3.f90: New test case.
2014-08-09 Jan Hubicka <hubicka@ucw.cz>
* g++.dg/ipa/devirt-35.C: Fix template.

View File

@ -0,0 +1,15 @@
! { dg-do compile }
! { dg-options "-fdump-tree-original" }
! PR 61999 - this used to ICE.
! Original test case by A. Kasahara
program main
use, intrinsic:: iso_fortran_env, only: output_unit
implicit none
write(output_unit, *) dot_product([1, 2], [2.0, 3.0])
stop
end program main
! { dg-final { scan-tree-dump-times "8\\.0e\\+0" 1 "original" } }
! { dg-final { cleanup-tree-dump "original" } }