From 3083fc562eb49c1df94453a17f9dbc37462ab0d0 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Wed, 18 Jan 2017 19:35:41 +0100 Subject: [PATCH] re PR fortran/70696 ([Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray) gcc/fortran/ChangeLog: 2017-01-17 Andre Vehreschild PR fortran/70696 Missed some parts, here they are: * trans-decl.c (gfc_build_qualified_array): Add static tokens to the parent function's scope. * trans-expr.c (gfc_get_tree_for_caf_expr): Shorten code. Remove unnecessary assert. gcc/testsuite/ChangeLog: 2017-01-17 Andre Vehreschild PR fortran/70696 * gfortran.dg/coarray_event_1.f08: New test. From-SVN: r244587 --- gcc/fortran/ChangeLog | 9 +++++++++ gcc/fortran/trans-decl.c | 2 ++ gcc/fortran/trans-expr.c | 9 ++++----- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/coarray_event_1.f08 | 15 +++++++++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/coarray_event_1.f08 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 191bfc816a7..a10444c8c0b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2017-01-17 Andre Vehreschild + + PR fortran/70696 + Missed some cases, here they are: + * trans-decl.c (gfc_build_qualified_array): Add static tokens to the + parent function's scope. + * trans-expr.c (gfc_get_tree_for_caf_expr): Shorten code. Remove + unnecessary assert. + 2017-01-13 Andre Vehreschild PR fortran/70697 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index fffb4928f1c..51c23e8c5df 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -971,6 +971,8 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) DECL_CONTEXT (token) = sym->ns->proc_name->backend_decl; gfc_module_add_decl (cur_module, token); } + else if (sym->attr.host_assoc) + gfc_add_decl_to_parent_function (token); else gfc_add_decl_to_function (token); } diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 01b7dd27dce..ee8e15d1753 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1839,11 +1839,10 @@ gfc_get_tree_for_caf_expr (gfc_expr *expr) } /* 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); + caf_decl = expr->symtree->n.sym->backend_decl == NULL_TREE + ? gfc_get_symbol_decl (expr->symtree->n.sym) + : expr->symtree->n.sym->backend_decl; + if (expr->symtree->n.sym->ts.type == BT_CLASS) { if (expr->ref && expr->ref->type == REF_ARRAY) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5b38a565881..01e71827258 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-17 Andre Vehreschild + + PR fortran/70696 + * gfortran.dg/coarray_event_1.f08: New test. + 2017-01-18 Jakub Jelinek PR target/77416 diff --git a/gcc/testsuite/gfortran.dg/coarray_event_1.f08 b/gcc/testsuite/gfortran.dg/coarray_event_1.f08 new file mode 100644 index 00000000000..51fc54c162a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_event_1.f08 @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib -lcaf_single" } + +! Check that pr70696 is really fixed. + + use iso_fortran_env + type(event_type) :: x[*] + + ! exchange must not be called or the link problem before the patch + ! does not occur. +contains + subroutine exchange + event post (x[1]) + end subroutine +end -- 2.30.2