summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvehre <vehre@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-28 11:34:03 +0000
committervehre <vehre@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-28 11:34:03 +0000
commitcc7124a6358668c08152b1938d3f1ce8f55a8897 (patch)
tree202e6b9c3587ff2377f83624c9407a69f6045c68
parent358dfcb4a1535bcdd89aced5b603802f40b597a6 (diff)
downloadgcc-cc7124a6358668c08152b1938d3f1ce8f55a8897.tar.gz
gcc/fortran/ChangeLog:
2016-01-28 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/62536 * decl.c (gfc_match_end): Only unnest and remove BLOCK namespaces when the END encountered does not match a BLOCK's end. gcc/testsuite/ChangeLog: 2016-01-28 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/62536 * gfortran.dg/block_15.f08: New test. * gfortran.dg/block_end_error_1.f90: Need to catch additional error on incorrectly closed BLOCK. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232919 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/decl.c7
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gfortran.dg/block_end_error_1.f902
4 files changed, 19 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 1ea9d29a2ec..386bd420281 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2016-01-28 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/62536
+ * decl.c (gfc_match_end): Only unnest and remove BLOCK namespaces
+ when the END encountered does not match a BLOCK's end.
+
2016-01-27 Janus Weil <janus@gcc.gnu.org>
PR fortran/69484
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 7c0e01124ac..df813697a02 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -6327,6 +6327,7 @@ gfc_match_end (gfc_statement *st)
gfc_namespace *parent_ns, *ns, *prev_ns;
gfc_namespace **nsp;
bool abreviated_modproc_decl;
+ bool got_matching_end = false;
old_loc = gfc_current_locus;
if (gfc_match ("end") != MATCH_YES)
@@ -6510,6 +6511,8 @@ gfc_match_end (gfc_statement *st)
? "END PROCEDURE" : gfc_ascii_statement(*st), &old_loc);
goto cleanup;
}
+ else
+ got_matching_end = true;
old_loc = gfc_current_locus;
/* If we're at the end, make sure a block name wasn't required. */
@@ -6581,7 +6584,7 @@ cleanup:
/* If we are missing an END BLOCK, we created a half-ready namespace.
Remove it from the parent namespace's sibling list. */
- while (state == COMP_BLOCK)
+ while (state == COMP_BLOCK && !got_matching_end)
{
parent_ns = gfc_current_ns->parent;
@@ -6601,7 +6604,7 @@ cleanup:
prev_ns = ns;
ns = ns->sibling;
}
-
+
gfc_free_namespace (gfc_current_ns);
gfc_current_ns = parent_ns;
gfc_state_stack = gfc_state_stack->previous;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fb29f731b2a..63b4b1ff13f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2016-01-28 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/62536
+ * gfortran.dg/block_15.f08: New test.
+ * gfortran.dg/block_end_error_1.f90: Need to catch additional error
+ on incorrectly closed BLOCK.
+
2016-01-28 Ilya Enkovich <enkovich.gnu@gmail.com>
* gcc.dg/declare-simd.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/block_end_error_1.f90 b/gcc/testsuite/gfortran.dg/block_end_error_1.f90
index e7dcdfa966d..4bbe89bba72 100644
--- a/gcc/testsuite/gfortran.dg/block_end_error_1.f90
+++ b/gcc/testsuite/gfortran.dg/block_end_error_1.f90
@@ -6,5 +6,5 @@ subroutine s
block
end block named ! { dg-error "Syntax error in END BLOCK statement" }
return
-endsubroutine
+endsubroutine ! { dg-error "Expecting END BLOCK statement" }
! { dg-prune-output "Unexpected end of file" }