diff mbox

Patch for fortran/62536 and fortran/66175

Message ID 14ee727ec7b.104544e4343297.1918480250807930593@zoho.com
State New
Headers show

Commit Message

Louis Krupp Aug. 1, 2015, 2:47 a.m. UTC
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.

Comments

FX Coudert Aug. 1, 2015, 8:47 a.m. UTC | #1
> 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.

The patch is OK.

But the question I missed in my earlier email was: do you have a copyright assignment in place with the FSF?

FX
FX Coudert Aug. 1, 2015, 5:16 p.m. UTC | #2
> No, I don't, but I would be happy to assign copyright. How do I do that? I've read this: https://www.fsf.org/licensing/assigning.html
> and it says I should "email the maintainer of the program communicating [my] desire to assign copyright.”

As I understand it, you need to fill this form: http://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/Copyright/request-assign.future (with “GCC” being the “package you’re contributing to”) and send it by email to assign@gnu.org to get the process started.

In past times, it used to take a little time. I don’t know what the current situation is.

FX
FX Coudert Aug. 24, 2015, 4:30 p.m. UTC | #3
> 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
diff mbox

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 226452)
+++ ChangeLog	(working copy)
@@ -1877,6 +1877,13 @@ 
 	* interface.c (is_procptr_result): New function to check if an
 	expression is a procedure-pointer result.
 	(compare_actual_formal): Use it.
+
+2015_07_31  Louis Krupp <louis.krupp@zoho.com>
+
+    PR fortran/62536 and fortran/66175
+	* decl.c (gfc_match_end): Clean up nested BLOCKs.
+	* parse.c (parse_block_construct): Deal gracefully with cleaned-up
+	BLOCKs.
 ^L
 Copyright (C) 2015 Free Software Foundation, Inc.
 
Index: decl.c
===================================================================
--- decl.c	(revision 226452)
+++ 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: parse.c
===================================================================
--- parse.c	(revision 226452)
+++ 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,15 @@  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 ();
 }