]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/56667 (Syntax error causes misleading message: "Expected PARAMETER...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 6 Mar 2018 19:30:41 +0000 (19:30 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 6 Mar 2018 19:30:41 +0000 (19:30 +0000)
2018-03-06  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/56667
* primary.c (match_sym_complex_part): Give the matcher for an implied
do-loop a chance to run.

2018-03-06  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/56667
* gfortran.dg/implied_do_2.f90: New test.
* gfortran.dg/coarray_8.f90: Update for new error message.

From-SVN: r258283

gcc/fortran/ChangeLog
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/coarray_8.f90
gcc/testsuite/gfortran.dg/implied_do_2.f90 [new file with mode: 0644]

index c9505c43d4fc973d089b5315d5d1cf1bea8226ed..60159842746d310b67c76f51dd2f544eaeed2755 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-06  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/56667
+       * primary.c (match_sym_complex_part): Give the matcher for an implied
+       do-loop a chance to run.
+
 2018-03-03  Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/71085
index 009ae99bbd42959ece9d0da205b8e5540a3d9fe9..a90beb17393d9318832efdbf869dbf90f477777e 100644 (file)
@@ -1250,8 +1250,22 @@ match_sym_complex_part (gfc_expr **result)
 
   if (sym->attr.flavor != FL_PARAMETER)
     {
-      gfc_error ("Expected PARAMETER symbol in complex constant at %C");
-      return MATCH_ERROR;
+      /* Give the matcher for implied do-loops a chance to run.  This yields
+        a much saner error message for "write(*,*) (i, i=1, 6" where the 
+        right parenthesis is missing.  */
+      char c;
+      gfc_gobble_whitespace ();
+      c = gfc_peek_ascii_char ();
+      if (c == '=' || c == ',')
+       {
+         m = MATCH_NO;
+       }
+      else
+       {
+         gfc_error ("Expected PARAMETER symbol in complex constant at %C");
+         m = MATCH_ERROR;
+       }
+      return m;
     }
 
   if (!sym->value)
index 1461d652a84216b88907348312c5d2aac597ef97..705b89d20d5e7b45572e220f1c10b41ea56727a2 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-06  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/56667
+       * gfortran.dg/implied_do_2.f90: New test.
+       * gfortran.dg/coarray_8.f90: Update for new error message.
+
 2018-03-03  Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/71085
index db6eb6c2e2d86be49f09b7b34f90ef70d8b5776a..060f94118ac6d45abc9330bddc78a9a1200a41c8 100644 (file)
@@ -145,7 +145,7 @@ end module mmm4
 
 subroutine tfgh()
   integer :: i(2)
-  DATA i/(i, i=1,2)/ ! { dg-error "Expected PARAMETER symbol" }
+  DATA i/(i, i=1,2)/ ! { dg-error "Syntax error in DATA" }
   do i = 1, 5 ! { dg-error "cannot be an array" }
   end do ! { dg-error "Expecting END SUBROUTINE" }
 end subroutine tfgh
@@ -153,7 +153,7 @@ end subroutine tfgh
 subroutine tfgh2()
   integer, save :: x[*]
   integer :: i(2)
-  DATA i/(x, x=1,2)/ ! { dg-error "Expected PARAMETER symbol" }
+  DATA i/(x, x=1,2)/ ! { dg-error "Syntax error in DATA" }
   do x = 1, 5 ! { dg-error "cannot be a coarray" }
   end do ! { dg-error "Expecting END SUBROUTINE" }
 end subroutine tfgh2
diff --git a/gcc/testsuite/gfortran.dg/implied_do_2.f90 b/gcc/testsuite/gfortran.dg/implied_do_2.f90
new file mode 100644 (file)
index 0000000..5078ac8
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/56667
+program error_message
+   implicit none
+   integer :: ir
+   write(*,*) ( ir, ir = 1,10    ! { dg-error "Expected a right parenthesis" }
+end program error_message