Tested on i586-*-freebsd. OK to commit?
2018-12-25 Steven G. Kargl <[email protected]>
PR fortran/81027
* expr.c (gfc_check_init_expr): Issue an error message for an
assumed-shape array as opposed to a deferred-shape array.
2018-12-25 Steven G. Kargl <[email protected]>
PR fortran/81027
* gfortran.dg/pr81027.f90: New test.
--
Steve
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 267418)
+++ gcc/fortran/expr.c (working copy)
@@ -2869,9 +2869,15 @@ gfc_check_init_expr (gfc_expr *e)
break;
case AS_DEFERRED:
- gfc_error ("Deferred array %qs at %L is not permitted "
- "in an initialization expression",
- e->symtree->n.sym->name, &e->where);
+ if (!e->symtree->n.sym->attr.allocatable
+ && e->symtree->n.sym->attr.dummy)
+ gfc_error ("Assumed-shape array %qs at %L is not permitted "
+ "in an initialization expression",
+ e->symtree->n.sym->name, &e->where);
+ else
+ gfc_error ("Deferred array %qs at %L is not permitted "
+ "in an initialization expression",
+ e->symtree->n.sym->name, &e->where);
break;
case AS_EXPLICIT:
Index: gcc/testsuite/gfortran.dg/pr81027.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr81027.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr81027.f90 (working copy)
@@ -0,0 +1,11 @@
+program badarray
+ implicit none
+ integer:: j(3) = [1,2,3]
+ call doubling(j)
+contains
+ subroutine doubling( n)
+ integer,intent(in)::n(:)
+ integer::m = size(n) ! { dg-error "is not permitted in an" }
+ print *, m ! { dg-error "has no IMPLICIT type" }
+ end subroutine doubling
+end program badarray