Re: [PATCH, Fortran, pr70696, v2] [Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray

2017-01-19 Thread Andre Vehreschild
Hi Steve,

thanks for the review. Committed as r244637.

Regards,
Andre

On Thu, 19 Jan 2017 06:51:19 -0800
Steve Kargl  wrote:

> On Thu, Jan 19, 2017 at 01:07:50PM +0100, Andre Vehreschild wrote:
> > Hi all,
> > 
> > unfortunately triggered this patch a regression in the opencoarray's
> > testsuite, which also occurs outside of opencoarray, when a caf-function is
> > used in a block in the main-program. This patch fixes the error and adds a
> > testcase.
> > 
> > Bootstrapped and regtested ok on x86_64-linux/f25. Ok for trunk?
> >   
> 
> Yes.
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 


Re: [PATCH, Fortran, pr70696, v2] [Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray

2017-01-19 Thread Steve Kargl
On Thu, Jan 19, 2017 at 01:07:50PM +0100, Andre Vehreschild wrote:
> Hi all,
> 
> unfortunately triggered this patch a regression in the opencoarray's 
> testsuite,
> which also occurs outside of opencoarray, when a caf-function is used in a
> block in the main-program. This patch fixes the error and adds a testcase.
> 
> Bootstrapped and regtested ok on x86_64-linux/f25. Ok for trunk?
> 

Yes.

-- 
Steve
20161221 https://www.youtube.com/watch?v=IbCHE-hONow


Re: [PATCH, Fortran, pr70696, v2] [Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray

2017-01-19 Thread Andre Vehreschild
Hi all,

unfortunately triggered this patch a regression in the opencoarray's testsuite,
which also occurs outside of opencoarray, when a caf-function is used in a
block in the main-program. This patch fixes the error and adds a testcase.

Bootstrapped and regtested ok on x86_64-linux/f25. Ok for trunk?

Regards,
Andre

On Wed, 18 Jan 2017 19:35:59 +0100
Andre Vehreschild  wrote:

> Hi Jerry,
> 
> thanks for the fast review. Committed as r244587.
> 
> Regards,
>   Andre
> 
> On Wed, 18 Jan 2017 09:38:40 -0800
> Jerry DeLisle  wrote:
> 
> > On 01/18/2017 04:26 AM, Andre Vehreschild wrote:  
> > > Hi all,
> > >
> > > the patch I proposed for this pr unfortunately did not catch all errors.
> > > Dominique figured, that the original testcase was not resolved (thanks for
> > > that).
> > >
> > > This patch resolves the linker problem by putting the static token into
> > > the parent function's decl list. Furthermore does the patch beautify the
> > > retrieval of the symbol in gfc_get_tree_for_caf_expr () and remove the
> > > following assert which is unnecessary then, because the symbol is either
> > > already present or created. And gfc_get_symbol_decl () can not return
> > > NULL.
> > >
> > > Bootstrapped and regtested ok on x86_64-linux/f25 and x86-linux/f25  for
> > > trunk. Bootstrapped and regtested ok on x86_64-linux/f25 for gcc-6
> > > (x86-linux has not been tested, because the VM is not that fast).
> > >
> > > Ok for trunk and gcc-6?
> > >
> > > Regards,
> > >   Andre
> > >
> > 
> > This one is OK, thanks.
> > 
> > Jerry  
> 
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
gcc/fortran/ChangeLog:

2017-01-19  Andre Vehreschild  

PR fortran/70696
* trans-decl.c (gfc_build_qualified_array): Add static decl to parent
function only, when the decl-context is not the translation unit.

gcc/testsuite/ChangeLog:

2017-01-19  Andre Vehreschild  

* gfortran.dg/coarray_43.f90: New test.


diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 51c23e8..5d246cd 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -971,7 +971,9 @@ 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)
+  else if (sym->attr.host_assoc
+	   && TREE_CODE (DECL_CONTEXT (current_function_decl))
+	   != TRANSLATION_UNIT_DECL)
 	gfc_add_decl_to_parent_function (token);
   else
 	gfc_add_decl_to_function (token);
diff --git a/gcc/testsuite/gfortran.dg/coarray_43.f90 b/gcc/testsuite/gfortran.dg/coarray_43.f90
new file mode 100644
index 000..d5ee4e1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_43.f90
@@ -0,0 +1,13 @@
+! { dg-do link }
+! { dg-options "-fcoarray=lib -lcaf_single" }
+
+program coarray_43
+  implicit none
+  integer, parameter :: STR_LEN = 50
+  character(len=STR_LEN) :: str[*]
+  integer :: pos
+  write(str,"(2(a,i2))") "Greetings from image ",this_image()," of ",num_images()
+  block
+pos = scan(str[5], set="123456789")
+  end block
+end program


Re: [PATCH, Fortran, pr70696, v2] [Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray

2017-01-18 Thread Andre Vehreschild
Hi Jerry,

thanks for the fast review. Committed as r244587.

Regards,
Andre

On Wed, 18 Jan 2017 09:38:40 -0800
Jerry DeLisle  wrote:

> On 01/18/2017 04:26 AM, Andre Vehreschild wrote:
> > Hi all,
> >
> > the patch I proposed for this pr unfortunately did not catch all errors.
> > Dominique figured, that the original testcase was not resolved (thanks for
> > that).
> >
> > This patch resolves the linker problem by putting the static token into the
> > parent function's decl list. Furthermore does the patch beautify the
> > retrieval of the symbol in gfc_get_tree_for_caf_expr () and remove the
> > following assert which is unnecessary then, because the symbol is either
> > already present or created. And gfc_get_symbol_decl () can not return NULL.
> >
> > Bootstrapped and regtested ok on x86_64-linux/f25 and x86-linux/f25  for
> > trunk. Bootstrapped and regtested ok on x86_64-linux/f25 for gcc-6
> > (x86-linux has not been tested, because the VM is not that fast).
> >
> > Ok for trunk and gcc-6?
> >
> > Regards,
> > Andre
> >  
> 
> This one is OK, thanks.
> 
> Jerry


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
Index: gcc/fortran/ChangeLog
===
--- gcc/fortran/ChangeLog	(Revision 244585)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -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
Index: gcc/fortran/trans-decl.c
===
--- gcc/fortran/trans-decl.c	(Revision 244585)
+++ gcc/fortran/trans-decl.c	(Arbeitskopie)
@@ -971,6 +971,8 @@
 	  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: gcc/fortran/trans-expr.c
===
--- gcc/fortran/trans-expr.c	(Revision 244585)
+++ gcc/fortran/trans-expr.c	(Arbeitskopie)
@@ -1839,11 +1839,10 @@
   }
 
   /* 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: gcc/testsuite/ChangeLog
===
--- gcc/testsuite/ChangeLog	(Revision 244585)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -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
Index: gcc/testsuite/gfortran.dg/coarray_event_1.f08
===
--- gcc/testsuite/gfortran.dg/coarray_event_1.f08	(nicht existent)
+++ gcc/testsuite/gfortran.dg/coarray_event_1.f08	(Arbeitskopie)
@@ -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 


Re: [PATCH, Fortran, pr70696, v2] [Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray

2017-01-18 Thread Jerry DeLisle

On 01/18/2017 04:26 AM, Andre Vehreschild wrote:

Hi all,

the patch I proposed for this pr unfortunately did not catch all errors.
Dominique figured, that the original testcase was not resolved (thanks for
that).

This patch resolves the linker problem by putting the static token into the
parent function's decl list. Furthermore does the patch beautify the
retrieval of the symbol in gfc_get_tree_for_caf_expr () and remove the following
assert which is unnecessary then, because the symbol is either already present
or created. And gfc_get_symbol_decl () can not return NULL.

Bootstrapped and regtested ok on x86_64-linux/f25 and x86-linux/f25  for trunk.
Bootstrapped and regtested ok on x86_64-linux/f25 for gcc-6 (x86-linux has not
been tested, because the VM is not that fast).

Ok for trunk and gcc-6?

Regards,
Andre



This one is OK, thanks.

Jerry