@@ -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)
new file mode 100644
@@ -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
@@ -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