diff mbox

[Fortran] Wrong invocation of caf_atomic_op

Message ID 540E9E97.6040602@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Sept. 9, 2014, 6:30 a.m. UTC
Alessandro Fanfarillo wrote:
> This email follows the previous without subject (sorry about that).

I think I'd prefer the following patch, which avoids a temporary if none 
is required. "value" is a pointer if the kind is the same (see kind 
check before) and if it is not a literal. Otherwise, it isn't a pointer 
and one needs to generate a temporary.

I do not quite understand why the current check doesn't work as both are 
integer(kind=4) but for some reasons one has a variant.

Additionally, I wonder whether one should add a test case – one probably 
should do – and of which kind (run test + fdump-tree-original?).

Tobias





> 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?
diff mbox

Patch

--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -8398,3 +8398,3 @@  conv_intrinsic_atomic_op (gfc_code *code)

- if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value)))
+ if (!POINTER_TYPE_P (TREE_TYPE (value)))
{