This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] fortran/66040 -- convert internal error into normal error


The attached patch has been regression tested on 
trunk.  OK to commit?

As shown by the testcase, each individual line of code 
is legal, but the ordering is incorrect.  This leads to
an ICE, which can be correctly reported as a user error.

2015-05-XX  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66040
	* parse.c(verify_st_order): Replace a gfc_internal_error with your
	generic gfc_error.

2015-05-XX  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66040
	* gfortran.dg/misplaced_statement.f90: New test.

-- 
Steve
Index: gcc/fortran/parse.c
===================================================================
--- gcc/fortran/parse.c	(revision 223094)
+++ gcc/fortran/parse.c	(working copy)
@@ -2425,8 +2425,7 @@ verify_st_order (st_state *p, gfc_statem
       break;
 
     default:
-      gfc_internal_error ("Unexpected %s statement in verify_st_order() at %C",
-			  gfc_ascii_statement (st));
+      return false;
     }
 
   /* All is well, record the statement in case we need it next time.  */
Index: gcc/testsuite/gfortran.dg/misplaced_statement.f90
===================================================================
--- gcc/testsuite/gfortran.dg/misplaced_statement.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/misplaced_statement.f90	(working copy)
@@ -0,0 +1,20 @@
+!{ dg-do compile }
+! PR fortran/66040
+!
+! Original code from Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+real function f1(x)
+   sequence          ! { dg-error "Unexpected SEQUENCE statement" }
+end function f1
+
+real function f2()
+   else              ! { dg-error "Unexpected ELSE statement" }
+end function f2
+
+real function f3()
+   block data        ! { dg-error "Unexpected BLOCK DATA statement" }
+end function f3
+
+real function f4()
+   program p         ! { dg-error "Unexpected PROGRAM statement" }
+end function f4

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]