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

login
register
mail settings
Submitter Tobias Burnus
Date Nov. 29, 2012, 9:07 a.m.
Message ID <50B725BD.60408@net-b.de>
Download mbox | patch
Permalink /patch/202686/
State New
Headers show

Comments

Tobias Burnus - Nov. 29, 2012, 9:07 a.m.
Tobias Burnus wrote:
> Committed as Rev. 193908

Looking at the code again, the condition for -fcoarray=lib was wrong and 
never triggered (-fcoarray=single was okay). Fixed by the following 
commit after building and regtesting.

Tobias

Patch

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 193923)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,6 +1,12 @@ 
 2012-11-28  Tobias Burnus  <burnus@net-b.de>
 
 	PR fortran/52161
+	* trans-stmt.c (gfc_trans_sync): Fix bound checking
+	for -fcoarray=lib.
+
+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>
Index: gcc/fortran/trans-stmt.c
===================================================================
--- gcc/fortran/trans-stmt.c	(Revision 193923)
+++ gcc/fortran/trans-stmt.c	(Arbeitskopie)
@@ -784,12 +784,12 @@  gfc_trans_sync (gfc_code *code, gfc_exec_op type)
       else
 	{
 	  tree cond2;
-	  cond = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
+	  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
 				  images, gfort_gvar_caf_num_images);
 	  cond2 = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
 				   images,
 				   build_int_cst (TREE_TYPE (images), 1));
-	  cond = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+	  cond = fold_build2_loc (input_location, TRUTH_OR_EXPR,
 				  boolean_type_node, cond, cond2);
 	}
       gfc_trans_runtime_check (true, false, cond, &se.pre,
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(Revision 193923)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@ 
+2012-11-28  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/52161
+	* coarray/sync_3.f90: Extend test.
+
 2012-11-29  Jakub Jelinek  <jakub@redhat.com>
 
 	PR rtl-optimization/55512
Index: gcc/testsuite/gfortran.dg/coarray/sync_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray/sync_3.f90	(Revision 193923)
+++ gcc/testsuite/gfortran.dg/coarray/sync_3.f90	(Arbeitskopie)
@@ -1,5 +1,6 @@ 
 ! { dg-do run }
 ! { dg-options "-fcheck=all" }
+! { dg-shouldfail "Invalid image number -1 in SYNC IMAGES" }
 !
 ! As sync_1, but with bounds checking enabled.
 ! PR fortran/52161
@@ -65,4 +66,10 @@  n = 5
 sync images (*,errmsg=str,stat=n)
 if (n /= 0) call abort()
 
+n = -1
+sync images ( num_images() )
+sync images (n) ! Invalid: "-1"
+
 end
+
+! { dg-output "Fortran runtime error: Invalid image number -1 in SYNC IMAGES" }