diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-01-20 20:33:34 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-01-20 20:33:34 +0000 |
commit | f5240750b71e8537f1f8418e9ee60656ecec3e28 (patch) | |
tree | 97f6691ea971071693660b3c5d891be8124a0bf4 /gcc/fortran/simplify.c | |
parent | 929b44113eec0c7f5d4a1ab9ff117736760deabe (diff) | |
download | gcc-f5240750b71e8537f1f8418e9ee60656ecec3e28.zip gcc-f5240750b71e8537f1f8418e9ee60656ecec3e28.tar.gz gcc-f5240750b71e8537f1f8418e9ee60656ecec3e28.tar.bz2 |
re PR fortran/83900 (ICE in gfc_simplify_matmul, at fortran/simplify.c:4593)
2018-01-20 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/83900
* simplify.c (gfc_simplify_matmul): Set return type correctly.
2018-01-20 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/83900
* gfortran.dg/matmul_18.f90: New test.
From-SVN: r256919
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r-- | gcc/fortran/simplify.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 0c48e7c..e2c63a5 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -4590,9 +4590,23 @@ gfc_simplify_matmul (gfc_expr *matrix_a, gfc_expr *matrix_b) || !is_constant_array_expr (matrix_b)) return NULL; - result = gfc_get_array_expr (matrix_a->ts.type, - matrix_a->ts.kind, - &matrix_a->where); + /* MATMUL should do mixed-mode arithmetic. Set the result type. */ + if (matrix_a->ts.type != matrix_b->ts.type) + { + gfc_expr e; + e.expr_type = EXPR_OP; + gfc_clear_ts (&e.ts); + e.value.op.op = INTRINSIC_NONE; + e.value.op.op1 = matrix_a; + e.value.op.op2 = matrix_b; + gfc_type_convert_binary (&e, 1); + result = gfc_get_array_expr (e.ts.type, e.ts.kind, &matrix_a->where); + } + else + { + result = gfc_get_array_expr (matrix_a->ts.type, matrix_a->ts.kind, + &matrix_a->where); + } if (matrix_a->rank == 1 && matrix_b->rank == 2) { |