]> 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:05:48 +0000 (19:05 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 6 Mar 2018 19:05:48 +0000 (19:05 +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: r258281

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 9a5b5670b0231e92d92819e2cad635edb5fa421e..f5b990d7694d8ee8d124fda2cc51637b68273b21 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 d889ed10ac38d7092737009ffb171286f698cac7..702010a026c6293169b6c69f5be2c643f60e7d77 100644 (file)
@@ -1248,8 +1248,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 edce5a57c50c83ad1328ceafa4fe735223d4b771..46a329aad3eb4cb9488c3e0270014d6770f4bd29 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-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR inline-asm/84683
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