From b2c298ab89d61ab36a68c3d9b694dac248532257 Mon Sep 17 00:00:00 2001 From: Alessandro Fanfarillo Date: Sat, 20 Sep 2014 08:14:08 -0600 Subject: [PATCH] trans-intrinsic.c (conv_intrinsic_atomic_op): Fix issue with generating temporary for value argument. 2014-09-20 Alessandro Fanfarillo Tobias Burnus gcc/fortran * trans-intrinsic.c (conv_intrinsic_atomic_op): Fix issue with generating temporary for value argument. gcc/testsuite/ * gfortran.dg/coarray_atomic_5.f90: New Co-Authored-By: Tobias Burnus From-SVN: r215421 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/trans-intrinsic.c | 2 +- gcc/testsuite/ChangeLog | 5 ++++ .../gfortran.dg/coarray_atomic_5.f90 | 26 +++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/coarray_atomic_5.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a96cf423493..389abf3fc1c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2014-09-20 Alessandro Fanfarillo + Tobias Burnus + + * trans-intrinsic.c (conv_intrinsic_atomic_op): Fix issue with + generating temporary for value argument. + 2014-09-20 Joost VandeVondele * trans-expr.c (gfc_reset_vptr): Fix comment whitespace. diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 0a83ad0219a..55079463b7d 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -8396,7 +8396,7 @@ conv_intrinsic_atomic_op (gfc_code *code) else image_index = integer_zero_node; - if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value))) + if (!POINTER_TYPE_P (TREE_TYPE (value))) { tmp = gfc_create_var (TREE_TYPE (TREE_TYPE (atom)), "value"); gfc_add_modify (&block, tmp, fold_convert (TREE_TYPE (tmp), value)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 130c6a75b1d..0ec7ad7ffa9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-09-20 Alessandro Fanfarillo + Tobias Burnus + + * gfortran.dg/coarray_atomic_5.f90: New + 2014-09-19 Jan Hubicka PR c++/61825 diff --git a/gcc/testsuite/gfortran.dg/coarray_atomic_5.f90 b/gcc/testsuite/gfortran.dg/coarray_atomic_5.f90 new file mode 100644 index 00000000000..11d52badef1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_atomic_5.f90 @@ -0,0 +1,26 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original -fcoarray=lib" } +! +! Argument passing was wrong +! + +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 + +! { dg-final { scan-tree-dump-times "value.. = 0;" 1 "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_caf_atomic_define \\(caf_token.0, 0, 1, &value.., 0B, 1, 4\\);" 1 "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_caf_atomic_op \\(1, caf_token.0, 0, 1, &me, 0B, 0B, 1, 4\\);" 1 "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_caf_atomic_ref \\(caf_token.0, 0, 1, &me, 0B, 1, 4\\);" 1 "original" } } +! { dg-final { cleanup-tree-dump "original" } }