This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR fortran/81027 -- Issue error for assumed-shape array
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortan at troutmask dot apl dot washington dot edu, gcc-patches at gcc dot gnu dot org
- Date: Tue, 25 Dec 2018 21:15:54 -0800
- Subject: [PATCH] PR fortran/81027 -- Issue error for assumed-shape array
- Reply-to: sgk at troutmask dot apl dot washington dot edu
Tested on i586-*-freebsd. OK to commit?
2018-12-25 Steven G. Kargl <kargl@gcc.gnu.org>
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 <kargl@gcc.gnu.org>
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