From 03b2d3defa7ef8c258d48f4bfbd66a08c27ea19c Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Thu, 27 Dec 2018 21:13:53 +0000 Subject: [PATCH] re PR fortran/81027 (Assumed-shape array reported as deferred.) 2018-12-27 Steven G. Kargl PR fortran/81027 * expr.c (gfc_check_init_expr): Distinguish assumed-shape versus deferred-shape dummy arguments in an error message. 2018-12-27 Steven G. Kargl PR fortran/81027 * gfortran.dg/pr81027.f90: New test. * gfortran.dg/initialization_7.f90: Update error message. From-SVN: r267437 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/expr.c | 13 ++++++++++--- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/initialization_7.f90 | 2 +- gcc/testsuite/gfortran.dg/pr81027.f90 | 11 +++++++++++ 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr81027.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index af5467f8fa4..827cd9622c1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-12-27 Steven G. Kargl + + PR fortran/81027 + * expr.c (gfc_check_init_expr): Distinguish assumed-shape versus + deferred-shape dummy arguments in an error message. + 2018-12-26 Harald Anlauf PR fortran/85407 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 7a018ae359a..638b38d141b 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2869,9 +2869,16 @@ 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.pointer + && 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: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 935f7da3b8e..302a6550e07 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-12-27 Steven G. Kargl + + PR fortran/81027 + * gfortran.dg/pr81027.f90: New test. + * gfortran.dg/initialization_7.f90: Update error message. + 2018-12-27 Steven G. Kargl * libgomp.fortran/aligned1.f03: Fix invalid code that now causes diff --git a/gcc/testsuite/gfortran.dg/initialization_7.f90 b/gcc/testsuite/gfortran.dg/initialization_7.f90 index 8615181965d..6a10075c5c5 100644 --- a/gcc/testsuite/gfortran.dg/initialization_7.f90 +++ b/gcc/testsuite/gfortran.dg/initialization_7.f90 @@ -6,7 +6,7 @@ subroutine probleme(p) real(kind=8), dimension(:) :: p - integer :: nx = size(p, 1) ! { dg-error "Deferred array" } + integer :: nx = size(p, 1) ! { dg-error "Assumed-shape array" } integer :: nix nix = nx diff --git a/gcc/testsuite/gfortran.dg/pr81027.f90 b/gcc/testsuite/gfortran.dg/pr81027.f90 new file mode 100644 index 00000000000..9f23daba04a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr81027.f90 @@ -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 "Assumed-shape array" } + print *, m ! { dg-error "has no IMPLICIT type" } + end subroutine doubling +end program badarray -- 2.30.2