[PATCH, Fortran] Wrong invocation of caf_atomic_op

Alessandro Fanfarillo fanfarillo.gcc@gmail.com
Mon Sep 8 22:27:00 GMT 2014


This email follows the previous without subject (sorry about that).

The attached patch solves the problem raised by the following code:

program atomic
use iso_fortran_env
implicit none

integer :: me
integer(atomic_int_kind) :: atom[*]
me = this_image()
call atomic_define(atom[1],0)
sync all
call ATOMIC_ADD (atom[1], me)
if(me == 1) call atomic_ref(me,atom[1])
sync all
write(*,*) me

end program


Ok for trunk?
-------------- next part --------------
2014-09-08  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
	    Tobias Burnus  <burnus@net-b.de>

	* trans-intrinsic.c (conv_intrinsic_atomic_op):
	Check for indirect reference for caf_atomic_op value.

Index: gcc/fortran/trans-intrinsic.c
===================================================================
*** gcc/fortran/trans-intrinsic.c	(revision 215016)
--- gcc/fortran/trans-intrinsic.c	(working copy)
*************** conv_intrinsic_atomic_op (gfc_code *code
*** 8397,8407 ****
  	image_index = integer_zero_node;
  
        if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value)))
! 	{
! 	  tmp = gfc_create_var (TREE_TYPE (TREE_TYPE (atom)), "value");
! 	  gfc_add_modify (&block, tmp, fold_convert (TREE_TYPE (tmp), value));
!           value = gfc_build_addr_expr (NULL_TREE, tmp);
! 	}
  
        gfc_get_caf_token_offset (&token, &offset, caf_decl, atom, atom_expr);
  
--- 8397,8409 ----
  	image_index = integer_zero_node;
  
        if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value)))
!  	{
!  	  tmp = gfc_create_var (TREE_TYPE (TREE_TYPE (atom)), "value");
! 	  if (POINTER_TYPE_P (TREE_TYPE (value)))
! 	    value = build_fold_indirect_ref_loc (input_location, value);
!  	  gfc_add_modify (&block, tmp, fold_convert (TREE_TYPE (tmp), value));
! 	  value = gfc_build_addr_expr (NULL_TREE, tmp);
!  	}
  
        gfc_get_caf_token_offset (&token, &offset, caf_decl, atom, atom_expr);
  


More information about the Gcc-patches mailing list