re PR fortran/81027 (Assumed-shape array reported as deferred.)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 27 Dec 2018 21:13:53 +0000 (21:13 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 27 Dec 2018 21:13:53 +0000 (21:13 +0000)
2018-12-27  Steven G. Kargl  <kargl@gcc.gnu.org>

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  <kargl@gcc.gnu.org>

PR fortran/81027
* gfortran.dg/pr81027.f90: New test.
* gfortran.dg/initialization_7.f90: Update error message.

From-SVN: r267437

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/initialization_7.f90
gcc/testsuite/gfortran.dg/pr81027.f90 [new file with mode: 0644]

index af5467f8fa405880255a8b785bd184aa30c59eab..827cd9622c17a2985850645275632ca5d97aa2cc 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-27  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       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  <anlauf@gmx.de>
 
        PR fortran/85407
index 7a018ae359ae095c13499772c3b32a7585f4794a..638b38d141b7e149611e63ac01fedb02fb7e4382 100644 (file)
@@ -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:
index 935f7da3b8e441fd7c402d9a103f6e6e57592939..302a6550e07856b8dc26ebfb391c0569220dff51 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-27  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/81027
+       * gfortran.dg/pr81027.f90: New test.
+       * gfortran.dg/initialization_7.f90: Update error message.
+
 2018-12-27  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        * libgomp.fortran/aligned1.f03: Fix invalid code that now causes
index 8615181965d6a3aadd80656d16ef1c3983bae8c7..6a10075c5c58eb8ae1f0faee75989a86b73fc995 100644 (file)
@@ -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 (file)
index 0000000..9f23dab
--- /dev/null
@@ -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