re PR fortran/77960 (ICE in gfc_conv_ss_startstride, at fortran/trans-array.c:3966)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 19 Jan 2019 21:18:26 +0000 (21:18 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 19 Jan 2019 21:18:26 +0000 (21:18 +0000)
2019-01-19  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/77960
* io.c (match_io_element): input-item cannot be an external function.

2019-01-19  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/77960
* gfortran.dg/pr77960.f90: New test.

From-SVN: r268097

gcc/fortran/ChangeLog
gcc/fortran/io.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr77960.f90 [new file with mode: 0644]

index c55cd7515f3015dcd4f170f3a6f7b917d326cdbb..6c95a879b24cdf303e32c67d08f9f9ff0b02ec92 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-19  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/77960
+       * io.c (match_io_element): input-item cannot be an external function.
 2018-01-19  Thomas Koenig  <tkoenig@gcc.gnu.org>
        Paul Thomas  <pault@gcc.gnu.org>
 
index 4ea37a331ca93386e0ed254a5a9b7998203271a5..fce9228c3026bc136a72600e2a9934a6f74afbde 100644 (file)
@@ -3610,6 +3610,16 @@ match_io_element (io_kind k, gfc_code **cpp)
       m = gfc_match_variable (&expr, 0);
       if (m == MATCH_NO)
        gfc_error ("Expected variable in READ statement at %C");
+
+      if (m == MATCH_YES
+         && expr->expr_type == EXPR_VARIABLE
+         && expr->symtree->n.sym->attr.external)
+       {
+         gfc_error ("Expecting variable or io-implied-do at %L",
+                    &expr->where);
+         m = MATCH_ERROR;
+       }
+
     }
   else
     {
index 286614dff12b913b6d061b32339203ea3673791b..f3c66ee318da18410bb48aebe975929e0ea32239 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-19  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/77960
+       * gfortran.dg/pr77960.f90: New test.
+
 2018-01-19  Thomas Koenig  <tkoenig@gcc.gnu.org>
        Paul Thomas  <pault@gcc.gnu.org>
 
diff --git a/gcc/testsuite/gfortran.dg/pr77960.f90 b/gcc/testsuite/gfortran.dg/pr77960.f90
new file mode 100644 (file)
index 0000000..6d9240e
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! PR fortran/77960
+   procedure(g), pointer :: f
+   f => g
+   read(99) f                 ! { dg-error "Expecting variable" }
+contains
+   function g() result(z)
+      integer :: z(2)
+      z = 1
+   end
+end
+
+subroutine bar(x)
+   integer, external :: x
+   read(*,*) x                ! { dg-error "Expecting variable" }
+end subroutine