Hi Jerry, thanks for the review. Committed as r244407.
Will backport to gcc-6 in a week or so. Regards, Andre On Thu, 12 Jan 2017 10:11:37 -0800 Jerry DeLisle <jvdeli...@charter.net> wrote: > On 01/12/2017 03:45 AM, Andre Vehreschild wrote: > > Hi all, > > > > attached patch fixes the ICE when using an event in a subroutine. The reason > > for the ICE was that the backend_decl of the symbol to event on was not set > > when accessed. The patch ensures this. Furthermore did I fix a invalid > > memory access in the caf_single lib, where to less memory was allocated in > > the registration of the event. > > > > Bootstraps and regtests ok on x86_64-linux/F25. Ok for trunk? > > > > Regards, > > Andre > > > > OK and thanks. > > Jerry -- Andre Vehreschild * Email: vehre ad gmx dot de
Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 244394) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,9 @@ +2017-01-13 Andre Vehreschild <ve...@gcc.gnu.org> + + PR fortran/70696 + * trans-expr.c (gfc_get_tree_for_caf_expr): Ensure the backend_decl + is valid before accessing it. + 2017-01-09 Jakub Jelinek <ja...@redhat.com> PR translation/79019 Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (Revision 244394) +++ gcc/fortran/trans-expr.c (Arbeitskopie) @@ -1838,6 +1838,10 @@ "component at %L is not supported", &expr->where); } + /* Make sure the backend_decl is present before accessing it. */ + if (expr->symtree->n.sym->backend_decl == NULL_TREE) + expr->symtree->n.sym->backend_decl + = gfc_get_symbol_decl (expr->symtree->n.sym); caf_decl = expr->symtree->n.sym->backend_decl; gcc_assert (caf_decl); if (expr->symtree->n.sym->ts.type == BT_CLASS) Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (Revision 244394) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,3 +1,8 @@ +2017-01-13 Andre Vehreschild <ve...@gcc.gnu.org> + + PR fortran/70696 + * gfortran.dg/coarray/event_3.f08: New test. + 2017-01-13 Richard Biener <rguent...@suse.de> PR tree-optimization/77283 Index: gcc/testsuite/gfortran.dg/coarray/event_3.f08 =================================================================== --- gcc/testsuite/gfortran.dg/coarray/event_3.f08 (nicht existent) +++ gcc/testsuite/gfortran.dg/coarray/event_3.f08 (Arbeitskopie) @@ -0,0 +1,20 @@ +! { dg-do run } +! +! Check PR fortran/70696 is fixed. + +program global_event + use iso_fortran_env , only : event_type + implicit none + type(event_type) :: x[*] + + call exchange + contains + subroutine exchange + integer :: cnt + event post(x[1]) + event post(x[1]) + call event_query(x, cnt) + if (cnt /= 2) error stop 1 + event wait(x, until_count=2) + end subroutine +end Index: libgfortran/ChangeLog =================================================================== --- libgfortran/ChangeLog (Revision 244394) +++ libgfortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,9 @@ +2017-01-13 Andre Vehreschild <ve...@gcc.gnu.org> + + PR fortran/70696 + * caf/single.c (_gfortran_caf_register): Allocate enough memory for + the event counter. + 2017-01-07 Andre Vehreschild <ve...@gcc.gnu.org> PR fortran/78781 Index: libgfortran/caf/single.c =================================================================== --- libgfortran/caf/single.c (Revision 244394) +++ libgfortran/caf/single.c (Arbeitskopie) @@ -141,9 +141,12 @@ caf_single_token_t single_token; if (type == CAF_REGTYPE_LOCK_STATIC || type == CAF_REGTYPE_LOCK_ALLOC - || type == CAF_REGTYPE_CRITICAL || type == CAF_REGTYPE_EVENT_STATIC - || type == CAF_REGTYPE_EVENT_ALLOC) + || type == CAF_REGTYPE_CRITICAL) local = calloc (size, sizeof (bool)); + else if (type == CAF_REGTYPE_EVENT_STATIC || type == CAF_REGTYPE_EVENT_ALLOC) + /* In the event_(wait|post) function the counter for events is a uint32, + so better allocate enough memory here. */ + local = calloc (size, sizeof (uint32_t)); else if (type == CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY) local = NULL; else