]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 1 Oct 2019 19:21:05 +0000 (19:21 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 1 Oct 2019 19:21:05 +0000 (19:21 +0000)
2019-10-01  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/91864
* gcc/fortran/io.c (match_io_element): An inquiry parameter cannot be
read into.
* gcc/fortran/match.c (gfc_match_allocate): An inquiry parameter
can be neither an allocate-object nor stat variable.
(gfc_match_deallocate): An inquiry parameter cannot be deallocated.

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

PR fortran/91864
* gcc/testsuite/gfortran.dg/pr91864.f90

From-SVN: r276425

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

index 691bca48e151de6b328939bb9d309e0046e20870..7e7e24c35fe6a48620e87829cf8e3f7f7cc3f9c0 100644 (file)
@@ -1,3 +1,12 @@
+2019-10-01  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/91864
+       * gcc/fortran/io.c (match_io_element): An inquiry parameter cannot be
+       read into.
+       * gcc/fortran/match.c (gfc_match_allocate): An inquiry parameter 
+       can be neither an allocate-object nor stat variable.
+       (gfc_match_deallocate): An inquiry parameter cannot be deallocated.
+
 2019-10-01  Steven G. Kargl  <kargl@gcc.ngu.org>
 
        Backport of r276254+276265
index 9bee9094e7f8345ffda5c1efa445c38a9732a3a0..4b0426f8f997018c31268f06aeb9e7d341718d48 100644 (file)
@@ -3608,7 +3608,17 @@ 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");
+       {
+         gfc_error ("Expecting variable in READ statement at %C");
+         m = MATCH_ERROR;
+       }
+
+      if (m == MATCH_YES && expr->expr_type == EXPR_CONSTANT)
+       {
+         gfc_error ("Expecting variable or io-implied-do in READ statement "
+                  "at %L", &expr->where);
+         m = MATCH_ERROR;
+       }
 
       if (m == MATCH_YES
          && expr->expr_type == EXPR_VARIABLE
@@ -3618,7 +3628,6 @@ match_io_element (io_kind k, gfc_code **cpp)
                     &expr->where);
          m = MATCH_ERROR;
        }
-
     }
   else
     {
index 2d91a2bbace4a8f697679f2b70df4e5131a60430..efc0c2d7bc31eb2d440f2276ff7a818e0c0dcf51 100644 (file)
@@ -4219,6 +4219,12 @@ gfc_match_allocate (void)
       if (m == MATCH_ERROR)
        goto cleanup;
 
+      if (tail->expr->expr_type == EXPR_CONSTANT)
+       {
+         gfc_error ("Unexpected constant at %C");
+         goto cleanup;
+       }
+
       if (gfc_check_do_variable (tail->expr->symtree))
        goto cleanup;
 
@@ -4351,6 +4357,12 @@ alloc_opt_list:
          tmp = NULL;
          saw_stat = true;
 
+         if (stat->expr_type == EXPR_CONSTANT)
+           {
+             gfc_error ("STAT tag at %L cannot be a constant", &stat->where);
+             goto cleanup;
+           }
+
          if (gfc_check_do_variable (stat->symtree))
            goto cleanup;
 
@@ -4627,6 +4639,12 @@ gfc_match_deallocate (void)
       if (m == MATCH_NO)
        goto syntax;
 
+      if (tail->expr->expr_type == EXPR_CONSTANT)
+       {
+         gfc_error ("Unexpected constant at %C");
+         goto cleanup;
+       }
+
       if (gfc_check_do_variable (tail->expr->symtree))
        goto cleanup;
 
index 949fa2f10c53b91b25fcf763d61b38e37a923bd2..f6095aba8fdd9c770ce0ced039751a407f937659 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-01 Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/91864
+       * gcc/testsuite/gfortran.dg/pr91864.f90
+
 2019-10-01  Steven G. Kargl  <kargl@gcc.ngu.org>
 
        PR fortran/91802
diff --git a/gcc/testsuite/gfortran.dg/pr91864.f90 b/gcc/testsuite/gfortran.dg/pr91864.f90
new file mode 100644 (file)
index 0000000..a17187d
--- /dev/null
@@ -0,0 +1,22 @@
+program p
+   integer :: i
+   read (*,*) i%kind   ! { dg-error "Expecting variable or io-implied-do" }
+end
+
+subroutine t
+   integer, allocatable :: x(:)
+   integer :: stat
+   allocate (x(3), stat=stat%kind)   ! { dg-error "cannot be a constant" }
+end
+
+subroutine u
+   integer, allocatable :: x(:)
+   integer :: stat
+   allocate (x(3), stat%kind=stat)   ! { dg-error "Unexpected constant" }
+end
+
+subroutine v
+   integer, allocatable :: x(:)
+   integer :: stat
+   deallocate (x, stat%kind=stat)   ! { dg-error "Unexpected constant" }
+end