From d8afd032fad763a31efe2da716da657bde7c556b Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Tue, 1 Aug 2017 19:09:02 +0000 Subject: re PR fortran/79312 (Empty array in assignment not correctly type-checked) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2017-08-01 Thomas König PR fortran/79312 * intrisic.c (gfc_convert_type_warn): Only set typespec for empty array constructors which don't have it already. 2017-08-01 Thomas König PR fortran/79312 * gfortran.dg/logical_assignment_1.f90: New test. From-SVN: r250792 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/intrinsic.c | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index bd9ecc3..7c10d8c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2017-08-01 Thomas König + + PR fortran/79312 + * intrisic.c (gfc_convert_type_warn): Only set typespec for + empty array constructors which don't have it already. + 2017-08-01 Thomas Koenig PR fortran/45435 diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index 2f60fe8..8965d50 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -4919,9 +4919,11 @@ gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag) if (ts->type == BT_UNKNOWN) goto bad; - /* NULL and zero size arrays get their type here. */ - if (expr->expr_type == EXPR_NULL - || (expr->expr_type == EXPR_ARRAY && expr->value.constructor == NULL)) + /* NULL and zero size arrays get their type here, unless they already have a + typespec. */ + if ((expr->expr_type == EXPR_NULL + || (expr->expr_type == EXPR_ARRAY && expr->value.constructor == NULL)) + && expr->ts.type == BT_UNKNOWN) { /* Sometimes the RHS acquire the type. */ expr->ts = *ts; -- cgit v1.1