trans-intrinsic.c (conv_intrinsic_atomic_op): Fix issue with generating temporary...
authorAlessandro Fanfarillo <fanfarillo.gcc@gmail.com>
Sat, 20 Sep 2014 14:14:08 +0000 (08:14 -0600)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 20 Sep 2014 14:14:08 +0000 (16:14 +0200)
2014-09-20  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
            Tobias Burnus  <burnus@net-b.de>

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 <burnus@net-b.de>
From-SVN: r215421

gcc/fortran/ChangeLog
gcc/fortran/trans-intrinsic.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/coarray_atomic_5.f90 [new file with mode: 0644]

index a96cf423493825c3bc6ba0deabd883d3831f2087..389abf3fc1cff3bacbdf354f785b701f52b6b8a7 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-20  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
+           Tobias Burnus  <burnus@net-b.de>
+
+       * trans-intrinsic.c (conv_intrinsic_atomic_op): Fix issue with
+       generating temporary for value argument.
+
 2014-09-20  Joost VandeVondele  <vondele@gcc.gnu.org>
 
        * trans-expr.c (gfc_reset_vptr): Fix comment whitespace.
index 0a83ad0219a90f76e67653040e036a450c0f9ad8..55079463b7d95b8d31c3c1790a3f4b52142a4faf 100644 (file)
@@ -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));
index 130c6a75b1d07efbb065a3d42a41f1d16836afb4..0ec7ad7ffa9e8e9ee97f202019ba635a5dd41d98 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-20  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
+           Tobias Burnus  <burnus@net-b.de>
+
+       * gfortran.dg/coarray_atomic_5.f90: New
+
 2014-09-19  Jan Hubicka  <hubicka@ucw.cz>
 
        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 (file)
index 0000000..11d52ba
--- /dev/null
@@ -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" } }