This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] Fix PR 79312, find invalid typespec for empty array constructors
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 24 Jul 2017 23:27:48 +0200
- Subject: [patch, fortran] Fix PR 79312, find invalid typespec for empty array constructors
- Authentication-results: sourceware.org; auth=none
Hello world,
the attached patch fixes the PR; patch and test case are rather
self-explanatory.
Regression-testing as I write this. OK for trunk if it passes?
Regards
Thomas
2017-07-24 Thomas König <tkoenig@gcc.gnu.org>
PR fortran/79312
* intrisic.c (gfc_convert_type_warn): Only set typespec for
empty array constructors which don't have it already.
2017-07-24 Thomas König <tkoenig@gcc.gnu.org>
PR fortran/79312
* gfortran.dg/logical_assignment_1.f90: New test.
Index: intrinsic.c
===================================================================
--- intrinsic.c (Revision 249936)
+++ intrinsic.c (Arbeitskopie)
@@ -4919,9 +4919,11 @@ gfc_convert_type_warn (gfc_expr *expr, gfc_typespe
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;
! { dg-do compile }
! PR 79312 - assigning a logical value to a real
! is invalid.
! Test case by John Harper.
program emptyarray5
implicit none
real a(0)
a = [logical::] ! { dg-error "Can't convert LOGICAL" }
print *,size(a)
end program emptyarray5