Patchwork [Fortran,committed] PR52161 - Fix bound checking of SYNC IMAGES( n )

login
register
mail settings
Submitter Tobias Burnus
Date Nov. 28, 2012, 9:57 p.m.
Message ID <50B688C3.9080300@net-b.de>
Download mbox | patch
Permalink /patch/202563/
State New
Headers show

Comments

Tobias Burnus - Nov. 28, 2012, 9:57 p.m.
Stupid bug of mine: When I cleaned up the code at some point, I forgot 
to change se.expr to "image" (se.expr is alway NULL_TREE at that point.)

Committed as Rev. 193908

Tobias

Patch

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 193907)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@ 
+2012-11-28  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/52161
+	* trans-stmt.c (gfc_trans_sync): Fix bound checking.
+
 2012-11-27  Tobias Burnus  <burnus@net-b.de>
 
 	PR fortran/55476
Index: gcc/fortran/trans-stmt.c
===================================================================
--- gcc/fortran/trans-stmt.c	(Revision 193907)
+++ gcc/fortran/trans-stmt.c	(Arbeitskopie)
@@ -795,7 +795,7 @@  gfc_trans_sync (gfc_code *code, gfc_exec_op type)
       gfc_trans_runtime_check (true, false, cond, &se.pre,
 			       &code->expr1->where, "Invalid image number "
 			       "%d in SYNC IMAGES",
-			       fold_convert (integer_type_node, se.expr));
+			       fold_convert (integer_type_node, images));
     }
 
    /* Per F2008, 8.5.1, a SYNC MEMORY is implied by calling the
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(Revision 193907)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@ 
+2012-11-28  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/52161
+	* coarray/sync_3.f90: New.
+
 2012-11-28  Uros Bizjak  <ubizjak@gmail.com>
 
 	* gcc.target/i386/pr55458.c: Require ia32 target instead of ilp32.
Index: gcc/testsuite/gfortran.dg/coarray/sync_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray/sync_3.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/coarray/sync_3.f90	(Arbeitskopie)
@@ -0,0 +1,68 @@ 
+! { dg-do run }
+! { dg-options "-fcheck=all" }
+!
+! As sync_1, but with bounds checking enabled.
+! PR fortran/52161
+!
+! Coarray support
+! PR fortran/18918
+
+implicit none
+integer :: n
+character(len=30) :: str
+critical
+end critical
+myCr: critical
+end critical myCr
+
+!
+! Test SYNC ALL
+!
+sync all
+sync all ( )
+sync all (errmsg=str)
+
+n = 5
+sync all (stat=n)
+if (n /= 0) call abort()
+
+n = 5
+sync all (stat=n,errmsg=str)
+if (n /= 0) call abort()
+
+
+!
+! Test SYNC MEMORY
+!
+sync memory
+sync memory ( )
+sync memory (errmsg=str)
+
+n = 5
+sync memory (stat=n)
+if (n /= 0) call abort()
+
+n = 5
+sync memory (errmsg=str,stat=n)
+if (n /= 0) call abort()
+
+
+!
+! Test SYNC IMAGES
+!
+sync images (*)
+if (this_image() == 1) then
+    sync images (1)
+    sync images (1, errmsg=str)
+    sync images ([1])
+end if
+
+n = 5
+sync images (*, stat=n)
+if (n /= 0) call abort()
+
+n = 5
+sync images (*,errmsg=str,stat=n)
+if (n /= 0) call abort()
+
+end