re PR fortran/70696 ([Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray)
authorAndre Vehreschild <vehre@gcc.gnu.org>
Fri, 13 Jan 2017 10:22:21 +0000 (11:22 +0100)
committerAndre Vehreschild <vehre@gcc.gnu.org>
Fri, 13 Jan 2017 10:22:21 +0000 (11:22 +0100)
gcc/testsuite/ChangeLog:

2017-01-13  Andre Vehreschild  <vehre@gcc.gnu.org>

PR fortran/70696
* gfortran.dg/coarray/event_3.f08: New test.

gcc/fortran/ChangeLog:

2017-01-13  Andre Vehreschild  <vehre@gcc.gnu.org>

PR fortran/70696
* trans-expr.c (gfc_get_tree_for_caf_expr): Ensure the backend_decl
is valid before accessing it.

libgfortran/ChangeLog:

2017-01-13  Andre Vehreschild  <vehre@gcc.gnu.org>

PR fortran/70696
* caf/single.c (_gfortran_caf_register): Allocate enough memory for
the event counter.

From-SVN: r244407

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/coarray/event_3.f08 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/caf/single.c

index 831b96847d1df70cf67beff920fc11750743cfc1..e979a3082392ec570b9933d33e4ef816dbc9a018 100644 (file)
@@ -1,3 +1,9 @@
+2017-01-13  Andre Vehreschild  <vehre@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  <jakub@redhat.com>
 
        PR translation/79019
index caaee6b42daa0d0dc6dd55bcc7aa6f26b27ba010..01b7dd27dced2dafe11d236c67c380abdf97a3d6 100644 (file)
@@ -1838,6 +1838,10 @@ gfc_get_tree_for_caf_expr (gfc_expr *expr)
                     "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 379eebea7594ed50fa91fa32740a46b8c3274db9..df14a1bc3350eee5614d56f2e5b7e227eb7b156c 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-13  Andre Vehreschild  <vehre@gcc.gnu.org>
+
+       PR fortran/70696
+       * gfortran.dg/coarray/event_3.f08: New test.
+
 2017-01-13  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/77283
diff --git a/gcc/testsuite/gfortran.dg/coarray/event_3.f08 b/gcc/testsuite/gfortran.dg/coarray/event_3.f08
new file mode 100644 (file)
index 0000000..f6e28b7
--- /dev/null
@@ -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 f07dff1b8d68561a257842c7ddd0d17a18c36460..1a687300a78faa70b0b828cc62bdc9168f67dc9a 100644 (file)
@@ -1,3 +1,9 @@
+2017-01-13  Andre Vehreschild  <vehre@gcc.gnu.org>
+
+       PR fortran/70696
+       * caf/single.c (_gfortran_caf_register): Allocate enough memory for
+       the event counter.
+
 2017-01-07  Andre Vehreschild  <vehre@gcc.gnu.org>
 
        PR fortran/78781
index cf78a1a48fdb656e2961f06db524a565b4869a23..8d3bcbfb80eedc91d189a3670771c07d41f5b932 100644 (file)
@@ -141,9 +141,12 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
   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