From: FX <fxcoudert@gmail.com>
To: Louis Krupp <louis.krupp@zoho.com>
Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: Patch for fortran/62536 and fortran/66175
Date: Mon, 24 Aug 2015 16:39:00 -0000 [thread overview]
Message-ID: <25EB6D73-E490-41BE-BA9A-55C7D5396AF2@gmail.com> (raw)
In-Reply-To: <14ee727ec7b.104544e4343297.1918480250807930593@zoho.com>
[-- Attachment #1: Type: text/plain, Size: 674 bytes --]
> This patch cleans up nested blocks when there's an unexpected end of a compilation unit (66175), and it handles cleaned-up blocks gracefully (62536). I've run "make check-fortran" with the attached test cases.
I have now committed the patch to trunk as revision 227135.
Thanks for your contribution! And you’re welcome to repeat that experience anytime :)
FYI, I fixed a few minor issues with the patch before committed it (final version attached):
- test directive should be { dg-do compile } not { dg-compile }
- comment reformatting
- missing gcc/testsuite/ChangeLog entries
- reformated date and PR entries in ChangeLog
Thanks again,
FX
[-- Attachment #2: block.diff --]
[-- Type: application/octet-stream, Size: 3506 bytes --]
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (revision 227134)
+++ gcc/fortran/ChangeLog (working copy)
@@ -1,3 +1,11 @@
+2015-08-24 Louis Krupp <louis.krupp@zoho.com>
+
+ PR fortran/62536
+ PR fortran/66175
+ * decl.c (gfc_match_end): Clean up nested BLOCKs.
+ * parse.c (parse_block_construct): Deal gracefully with cleaned-up
+ BLOCKs.
+
2015-08-23 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR libfortran/54572
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 227127)
+++ gcc/fortran/decl.c (working copy)
@@ -6483,7 +6483,7 @@ cleanup:
/* If we are missing an END BLOCK, we created a half-ready namespace.
Remove it from the parent namespace's sibling list. */
- if (state == COMP_BLOCK)
+ while (state == COMP_BLOCK)
{
parent_ns = gfc_current_ns->parent;
@@ -6506,6 +6506,8 @@ cleanup:
gfc_free_namespace (gfc_current_ns);
gfc_current_ns = parent_ns;
+ gfc_state_stack = gfc_state_stack->previous;
+ state = gfc_current_state ();
}
return MATCH_ERROR;
Index: gcc/fortran/parse.c
===================================================================
--- gcc/fortran/parse.c (revision 227127)
+++ gcc/fortran/parse.c (working copy)
@@ -3935,6 +3935,7 @@ static void
parse_block_construct (void)
{
gfc_namespace* my_ns;
+ gfc_namespace* my_parent;
gfc_state_data s;
gfc_notify_std (GFC_STD_F2008, "BLOCK construct at %C");
@@ -3948,10 +3949,14 @@ parse_block_construct (void)
push_state (&s, COMP_BLOCK, my_ns->proc_name);
gfc_current_ns = my_ns;
+ my_parent = my_ns->parent;
parse_progunit (ST_NONE);
- gfc_current_ns = gfc_current_ns->parent;
+ /* Don't depend on the value of gfc_current_ns; it might have been
+ reset if the block had errors and was cleaned up. */
+ gfc_current_ns = my_parent;
+
pop_state ();
}
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (revision 227134)
+++ gcc/testsuite/ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2015-08-24 Louis Krupp <louis.krupp@zoho.com>
+
+ PR fortran/62536
+ PR fortran/66175
+ * gfortran.dg/block_end_error_1.f90: New test.
+ * gfortran.dg/blocks_nested_incomplete_1.f90: New test.
+
2015-08-24 H.J. Lu <hongjiu.lu@intel.com>
PR target/66821
Index: gcc/testsuite/gfortran.dg/block_end_error_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/block_end_error_1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/block_end_error_1.f90 (working copy)
@@ -0,0 +1,10 @@
+! { dg-do compile }
+!
+! PR fortran/62536
+! Bad "end block" causes ICE.
+subroutine s
+ block
+ end block named ! { dg-error "Syntax error in END BLOCK statement" }
+ return
+endsubroutine
+! { dg-prune-output "Unexpected end of file" }
Index: gcc/testsuite/gfortran.dg/blocks_nested_incomplete_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/blocks_nested_incomplete_1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/blocks_nested_incomplete_1.f90 (working copy)
@@ -0,0 +1,9 @@
+! { dg-do compile }
+!
+! PR fortran/66175
+! Nested incomplete blocks cause ICE.
+program main
+ block
+ block
+end program ! { dg-error "Expecting END BLOCK statement" }
+! { dg-prune-output "Unexpected end of file" }
prev parent reply other threads:[~2015-08-24 16:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-01 2:47 Louis Krupp
2015-08-01 8:48 ` FX
[not found] ` <14eea3fb99b.f2ce052556271.8598774328060804314@zoho.com>
2015-08-01 17:16 ` FX
2015-08-24 16:39 ` FX [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25EB6D73-E490-41BE-BA9A-55C7D5396AF2@gmail.com \
--to=fxcoudert@gmail.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=louis.krupp@zoho.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).