public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fortran/66040 -- convert internal error into normal error
@ 2015-05-15 14:59 Steve Kargl
  2015-05-15 20:41 ` FX
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2015-05-15 14:59 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

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

[-- Attachment #2: pr66040.diff --]
[-- Type: text/x-diff, Size: 1334 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fortran/66040 -- convert internal error into normal error
  2015-05-15 14:59 [PATCH] fortran/66040 -- convert internal error into normal error Steve Kargl
@ 2015-05-15 20:41 ` FX
  0 siblings, 0 replies; 2+ messages in thread
From: FX @ 2015-05-15 20:41 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

> 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.

OK

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-15 20:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-15 14:59 [PATCH] fortran/66040 -- convert internal error into normal error Steve Kargl
2015-05-15 20:41 ` FX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).