diff mbox

[PR,fortran/60774] Patch

Message ID 20160818204316.GA91579@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl Aug. 18, 2016, 8:43 p.m. UTC
If no one objects, I would like to commit the
following patch on Saturday.

Note, Bud Davis found the location of the problem for
free-form code and proposed a fixed.  I've modified his
proposed patch and applied a similar change for fixed-form.

Previously, gfortran would issue a warning and reject a
statement label on a line by itself (leading to and ICE).
The patch will cause an error to be emitted and the invalid
line of code is accepted.

Also note, label_3.f90 and empty_label.f90 are essentially
identical code.  I intend to delete label_3.f90 when I 
commit, but here I've included the diff for label_3.f90.

2016-08-20  Steven G. Kargl  <kargl@gcc.gnu.org>
	    Bud Davis  <jmdavis@link.com>

	* parse.c (next_free,next_fixed): Issue error for statement label
	without a statement.

2016-08-20  Steven G. Kargl  <kargl@gcc.gnu.org>
	* gfortran.dg/empty_label.f: Adjust test for new error message.
	* gfortran.dg/empty_label.f90: Ditto.
	* gfortran.dg/empty_label_typedecl.f90: Ditto.
	* gfortran.dg/label_3.f90: Ditto.
	* gfortran.dg/warnings_are_errors_1.f90: Remove invlid statement label.
diff mbox

Patch

Index: gcc/fortran/parse.c
===================================================================
--- gcc/fortran/parse.c	(revision 239543)
+++ gcc/fortran/parse.c	(working copy)
@@ -1071,13 +1071,8 @@  next_free (void)
 	    }
 
 	  if (gfc_match_eos () == MATCH_YES)
-	    {
-	      gfc_warning_now (0, "Ignoring statement label in empty statement "
-			       "at %L", &label_locus);
-	      gfc_free_st_label (gfc_statement_label);
-	      gfc_statement_label = NULL;
-	      return ST_NONE;
-	    }
+	    gfc_error_now ("Statement label without statement at %L",
+			   &label_locus);
 	}
     }
   else if (c == '!')
@@ -1333,8 +1328,7 @@  next_fixed (void)
 
 blank_line:
   if (digit_flag)
-    gfc_warning_now (0, "Ignoring statement label in empty statement at %L",
-		     &label_locus);
+    gfc_error_now ("Statement label without statement at %L", &label_locus);
 
   gfc_current_locus.lb->truncated = 0;
   gfc_advance_line ();
Index: gcc/testsuite/gfortran.dg/empty_label.f
===================================================================
--- gcc/testsuite/gfortran.dg/empty_label.f	(revision 239543)
+++ gcc/testsuite/gfortran.dg/empty_label.f	(working copy)
@@ -1,7 +1,4 @@ 
 C { dg-do compile }
-C { dg-options "-Werror -fmax-errors=1" }
-100   ! { dg-error "empty statement" }
+100   ! { dg-error "Statement label without statement" }
       end
-subroutine foo ! Not checked ...
-end function ! ... but an error
-C { dg-excess-errors "warnings being treated as errors" }
+
Index: gcc/testsuite/gfortran.dg/empty_label.f90
===================================================================
--- gcc/testsuite/gfortran.dg/empty_label.f90	(revision 239543)
+++ gcc/testsuite/gfortran.dg/empty_label.f90	(working copy)
@@ -1,7 +1,3 @@ 
 ! { dg-do compile }
-! { dg-options "-Werror -fmax-errors=1" }
-100   ! { dg-error "empty statement" }
+100   ! { dg-error "Statement label without statement" }
 end
-subroutine foo ! Not checked ...
-end function ! ... but an error
-! { dg-excess-errors "warnings being treated as errors" }
Index: gcc/testsuite/gfortran.dg/empty_label_typedecl.f90
===================================================================
--- gcc/testsuite/gfortran.dg/empty_label_typedecl.f90	(revision 239543)
+++ gcc/testsuite/gfortran.dg/empty_label_typedecl.f90	(working copy)
@@ -1,8 +1,6 @@ 
 ! { dg-do compile }
-! { dg-options "-Werror" }
 subroutine s
   type t
-  1 ! { dg-error "empty statement" }
+  1 ! { dg-error "Statement label without statement" }
   end type
 end subroutine
-! { dg-excess-errors "warnings being treated as errors" }
Index: gcc/testsuite/gfortran.dg/label_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/label_3.f90	(revision 239543)
+++ gcc/testsuite/gfortran.dg/label_3.f90	(working copy)
@@ -1,5 +1,5 @@ 
 ! { dg-do compile }
 ! PR fortran/25756.
 ! This used to ICE due to the space after the label.
-1 ! { dg-warning "Ignoring statement label in empty statement" }
+1 ! { dg-error "Statement label without statement" }
 end
Index: gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90	(revision 239543)
+++ gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90	(working copy)
@@ -20,8 +20,6 @@ 
 1234  complex :: cplx ! { dg-error "defined but cannot be used" }
       cplx = 20.
 
-! gfc_warning_now:
- 1 ! { dg-error "Ignoring statement label in empty statement" }
        end
 ! { dg-final { output-exists-not } }
 ! { dg-excess-errors "warnings being treated as errors" }