diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-02-02 09:50:58 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-02-02 09:50:58 +0000 |
commit | 9e5e87d91f058dfde84258615efe6d773e01f72b (patch) | |
tree | 0496b4b0755833aa8aaae77c8eb7e594bdb2a796 /gcc/fortran/decl.c | |
parent | 415da7f3e0ad1b928ab6145d69dba109533fe772 (diff) | |
download | gcc-9e5e87d91f058dfde84258615efe6d773e01f72b.tar.gz |
2013-02-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/50627
PR fortran/56054
* decl.c (gfc_match_end): Remove half-ready namespace
from parent if the end of a block is missing.
* parse.c (parse_module): Do not put namespace into
gsymbol on error.
2013-02-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/50627
PR fortran/56054
* gfortran.dg/block_12.f90: New test.
* gfortran.dg/module_error_1.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195684 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 2a6342c681c..72c511c8b24 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -5955,6 +5955,8 @@ gfc_match_end (gfc_statement *st) const char *target; int eos_ok; match m; + gfc_namespace *parent_ns, *ns, *prev_ns; + gfc_namespace **nsp; old_loc = gfc_current_locus; if (gfc_match ("end") != MATCH_YES) @@ -6180,6 +6182,35 @@ syntax: cleanup: gfc_current_locus = old_loc; + + /* 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) + { + parent_ns = gfc_current_ns->parent; + + nsp = &(gfc_state_stack->previous->tail->ext.block.ns); + + prev_ns = NULL; + ns = *nsp; + while (ns) + { + if (ns == gfc_current_ns) + { + if (prev_ns == NULL) + *nsp = NULL; + else + prev_ns->sibling = ns->sibling; + } + prev_ns = ns; + ns = ns->sibling; + } + + gfc_free_namespace (gfc_current_ns); + gfc_current_ns = parent_ns; + } + return MATCH_ERROR; } |