+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
/* 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;
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;
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");
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 ();
}
+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
--- /dev/null
+! { 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" }
--- /dev/null
+! { 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" }