re PR fortran/70696 ([Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray)
authorAndre Vehreschild <vehre@gcc.gnu.org>
Wed, 18 Jan 2017 18:35:41 +0000 (19:35 +0100)
committerAndre Vehreschild <vehre@gcc.gnu.org>
Wed, 18 Jan 2017 18:35:41 +0000 (19:35 +0100)
gcc/fortran/ChangeLog:

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

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  <vehre@gcc.gnu.org>

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

From-SVN: r244587

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/coarray_event_1.f08 [new file with mode: 0644]

index 191bfc816a71178eb4e1de04bcf672233a2dfb08..a10444c8c0b6a8bda49d1e8c3f9a58ad68f06454 100644 (file)
@@ -1,3 +1,12 @@
+2017-01-17  Andre Vehreschild  <vehre@gcc.gnu.org>
+
+       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  <vehre@gcc.gnu.org>
 
        PR fortran/70697
index fffb4928f1ce84158a9b11445ad91d48d1cdce7c..51c23e8c5df910f01c5098f2e3a15f8ed82d1657 100644 (file)
@@ -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);
     }
index 01b7dd27dced2dafe11d236c67c380abdf97a3d6..ee8e15d17538f1a8dee526191aa12634ad57ea6a 100644 (file)
@@ -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)
index 5b38a5658818a3507e3efda58864043b7b176b90..01e71827258c03c49d905681b91c0f9339b44980 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-17  Andre Vehreschild  <vehre@gcc.gnu.org>
+
+       PR fortran/70696
+       * gfortran.dg/coarray_event_1.f08: New test.
+
 2017-01-18  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..51fc54c
--- /dev/null
@@ -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