From: Steven Bosscher Date: Mon, 15 Dec 2014 18:37:59 +0000 (+0000) Subject: re PR fortran/61669 (Error recovery ICE) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d5e2274d7996cf8272a6c23152b347e8692d61f3;p=gcc.git re PR fortran/61669 (Error recovery ICE) PR fortran/61669 * gfortran.h (struct gfc_namespace): Add OLD_DATA field. * decl.c (gfc_reject_data): New function. * parse.c *use_modules): Record roll-back point. (next_statement): Likewise. (reject_statement): Roll back to last accepted DATA. * gfortran.dg/pr61669.f90: New test. Co-Authored-By: Jakub Jelinek From-SVN: r218757 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 033582431d0..83f2aba8373 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2014-12-15 Steven Bosscher + + PR fortran/61669 + * gfortran.h (struct gfc_namespace): Add OLD_DATA field. + * decl.c (gfc_reject_data): New function. + * parse.c *use_modules): Record roll-back point. + (next_statement): Likewise. + (reject_statement): Roll back to last accepted DATA. + 2014-12-15 Janus Weil PR fortran/63727 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 1c648735ae6..28a7aca6638 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -178,6 +178,20 @@ gfc_free_data_all (gfc_namespace *ns) } } +/* Reject data parsed since the last restore point was marked. */ + +void +gfc_reject_data (gfc_namespace *ns) +{ + gfc_data *d; + + while (ns->data && ns->data != ns->old_data) + { + d = ns->data->next; + free (ns->data); + ns->data = d; + } +} static match var_element (gfc_data_variable *); diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 42ed8eb0fff..e0e5838504e 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1627,7 +1627,7 @@ typedef struct gfc_namespace gfc_st_label *st_labels; /* This list holds information about all the data initializers in this namespace. */ - struct gfc_data *data; + struct gfc_data *data, *old_data; gfc_charlen *cl_list, *old_cl_list; @@ -2929,6 +2929,7 @@ void gfc_free_omp_namelist (gfc_omp_namelist *); void gfc_free_equiv (gfc_equiv *); void gfc_free_equiv_until (gfc_equiv *, gfc_equiv *); void gfc_free_data (gfc_data *); +void gfc_reject_data (gfc_namespace *); void gfc_free_case_list (gfc_case *); /* matchexp.c -- FIXME too? */ diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index ad3137bdeba..54c0cdc13fa 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -119,6 +119,7 @@ use_modules (void) gfc_warning_check (); gfc_current_ns->old_cl_list = gfc_current_ns->cl_list; gfc_current_ns->old_equiv = gfc_current_ns->equiv; + gfc_current_ns->old_data = gfc_current_ns->data; last_was_use_stmt = false; } @@ -1098,6 +1099,7 @@ next_statement (void) gfc_current_ns->old_cl_list = gfc_current_ns->cl_list; gfc_current_ns->old_equiv = gfc_current_ns->equiv; + gfc_current_ns->old_data = gfc_current_ns->data; for (;;) { gfc_statement_label = NULL; @@ -2043,6 +2045,8 @@ reject_statement (void) gfc_free_equiv_until (gfc_current_ns->equiv, gfc_current_ns->old_equiv); gfc_current_ns->equiv = gfc_current_ns->old_equiv; + gfc_reject_data (gfc_current_ns); + gfc_new_block = NULL; gfc_undo_symbols (); gfc_clear_warning (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index af88c0aada9..77bd81bbc3b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-12-15 Steven Bosscher + Jakub Jelinek + + PR fortran/61669 + * gfortran.dg/pr61669.f90: New test. + 2014-12-15 Richard Biener PR tree-optimization/64312 diff --git a/gcc/testsuite/gfortran.dg/pr61669.f90 b/gcc/testsuite/gfortran.dg/pr61669.f90 new file mode 100644 index 00000000000..5bceafda762 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr61669.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } + write (*,"(a)") char(12) + CHARACTER*80 A /"A"/ ! { dg-error "Unexpected data declaration statement" } + REAL*4 B ! { dg-error "Unexpected data declaration statement" } + write (*,"(a)") char(12) + DATA B / 0.02 / ! { dg-warning "Obsolescent feature: DATA statement" } + END