public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <burnus@net-b.de>
To: gcc-patches <gcc-patches@gcc.gnu.org>, gfortran <fortran@gcc.gnu.org>
Subject: [Patch, Fortran] Fix ATOMIC checks
Date: Sun, 01 Mar 2015 22:36:00 -0000	[thread overview]
Message-ID: <54F3944A.5000800@net-b.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 124 bytes --]

This patch changes the coarray/coindexed check to match what the error 
message already claimed.

OK for the trunk?

Tobias

[-- Attachment #2: atomic.diff --]
[-- Type: text/x-patch, Size: 1616 bytes --]

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 3be4fb1..cdb5ff1 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -1022,7 +1022,7 @@ gfc_check_atomic (gfc_expr *atom, int atom_no, gfc_expr *value, int val_no,
       return false;
     }
 
-  if (!gfc_expr_attr (atom).codimension)
+  if (!gfc_is_coarray (atom) && !gfc_is_coindexed (atom))
     {
       gfc_error ("ATOM argument at %L of the %s intrinsic function shall be a "
 		 "coarray or coindexed", &atom->where, gfc_current_intrinsic);
diff --git a/gcc/testsuite/gfortran.dg/coarray_atomic_6.f90 b/gcc/testsuite/gfortran.dg/coarray_atomic_6.f90
new file mode 100644
index 0000000..ae155ec
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_atomic_6.f90
@@ -0,0 +1,36 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+! Contributed by Reinhold Bader
+!
+!
+program def_and_ref
+! compile only
+  use, intrinsic :: iso_fortran_env
+  implicit none
+  type :: e
+    integer(kind=atomic_int_kind) :: ia = 0
+    logical(kind=atomic_logical_kind) :: la = .false.
+  end type 
+
+  type(e) :: a[*]
+  
+  integer :: ival = 0
+  logical :: lval = .false.
+
+  if (this_image() == 1) then
+    call atomic_define(a[num_images()]%ia, 4)
+    call atomic_define(a[num_images()]%la, .true.)
+  end if
+  if (this_image() == num_images()) then
+    do while (ival == 0 .and. .not. lval)
+       call atomic_ref(ival, a%ia)
+       call atomic_ref(lval, a%la)
+    end do
+    if (ival == 4 .and. lval) then
+      write(*,*) 'OK'
+    else
+      write(*,*) 'FAIL: ival,lval =', ival, lval
+    end if
+  end if
+end program

             reply	other threads:[~2015-03-01 22:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-01 22:36 Tobias Burnus [this message]
2015-03-02  9:31 ` Paul Richard Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54F3944A.5000800@net-b.de \
    --to=burnus@net-b.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).